
Unity
KillJUMP
这个作者很懒,什么都没留下…
展开
-
unity感觉不错的dijkstra寻路算法插件(非grid-based,为node-based)
其中的OnPathFound是回调函数,表示一旦结果算出后,这个回调函数会被触发。回调函数读取List nodes。(如果你在scene有pathfinder脚本,可以直接访问到它)1.访问从Node1到node10的最小路径。首先要using QpathFinder。免费:上述是下载地址。原创 2023-03-02 10:42:13 · 417 阅读 · 0 评论 -
unity调用python
unity调用python原创 2022-10-10 15:23:51 · 994 阅读 · 0 评论 -
实现右键菜单栏 unity protips插件
实现右键菜单栏,右键弹出,移开关闭,点击后消失的效果原创 2022-08-26 17:29:03 · 724 阅读 · 0 评论 -
生成三角形棋盘格 triangle
生成三角形棋盘格triangle。原创 2022-07-19 15:31:28 · 246 阅读 · 0 评论 -
简单的音频播放器AudioController unity脚本
简单的音频播放器AudioController unity脚本原创 2022-07-13 00:56:22 · 1712 阅读 · 0 评论 -
如何解决在editor模式下 无法删除物体的问题
在编辑模式下,发现无论用DestroyImmediate或者是Destroy,都会报错,用上面的方法就不报错了。亲测有效!原创 2022-06-30 18:22:52 · 456 阅读 · 0 评论 -
卡通shader
Toon shader原创 2022-06-24 12:36:00 · 183 阅读 · 0 评论 -
光照相关 shader
物体的漫反射=环境色+kd*灯光强*max(0,dot(n,l))环境色=用一个常数来表示kd=物体对光的反射系数n,l分别是单位向量,n需要用UnityObjectToWorldNormal处理,最后normalize,l如果是平行灯无位置概念,可以直接用_WorldSpaceLightPos0来获取。高光反射=高光的颜色*ks*pow((max(0,dot(R,V)),gloss)ks反射系数R反射单位向量,是L根据N对称过去的量,=2*dot(N,L)*N-L或者=reflect(-L,N)V顶点到观原创 2022-06-19 16:38:18 · 577 阅读 · 0 评论 -
一个接口:支持三角形无限组合
一个接口:支持三角形无限组合原创 2022-06-11 17:49:50 · 121 阅读 · 0 评论 -
获得2D平面向量的垂直向量
获得2D平面向量的垂两个直向量原创 2022-06-10 17:56:40 · 982 阅读 · 0 评论 -
Rigidbody2d SweepTest Rigidbody2D.Cast 但用于rotation 旋转
Rigidbody2d SweepTest Rigidbody2D.Cast 但用于rotation 旋转SweepTest() for object rotation原创 2022-06-08 16:36:22 · 243 阅读 · 0 评论 -
rigidbody2d 围绕某固定点point进行旋转rotate
rigidbody2d 围绕某点进行旋转rotate原创 2022-06-08 11:37:06 · 353 阅读 · 0 评论 -
Unity 点击生成物体,移动拖拽物体
using System.Collections;using System.Collections.Generic;using UnityEngine;namespace DigitalRubyShared{ public class DemoScriptLagTest : MonoBehaviour { private Vector2 offset; public GameObject _picture; private voi.原创 2022-05-13 17:14:10 · 1810 阅读 · 2 评论 -
unity c# 泛型 洗牌
// Copyright (C) 2019-2021 gamevanilla. All rights reserved.// This code can only be used under the standard Unity Asset Store End User License Agreement,// a copy of which is available at http://unity3d.com/company/legal/as_terms.using System;using .原创 2022-04-26 18:05:46 · 1872 阅读 · 0 评论 -
gameframework UIGroup
其中,越下面的父物体在hierarchy面板中生成的越靠前,但最终显示优先级还是按照Depth,Depth越高,界面越靠近屏幕正对面的玩家。(图中的为15depthAbtop层最前面),一般不同层保持1个depth的差异即可实现功能。同一个group层之间的界面会有互斥性,打开一个会关闭另一个。不同层则没有,可以多开。————其他各个界面位于哪个UI,在UIForm里的UIGroupName中配即可...原创 2022-03-29 16:06:16 · 399 阅读 · 0 评论 -
unity3d 如何旋转terrain 地形文件
using System.Collections;using System.Collections.Generic;using UnityEditor;using UnityEngine;public class terraintest : MonoBehaviour{ // Start is called before the first frame update void Start() { } // Update is cal.原创 2022-03-24 10:16:48 · 6709 阅读 · 0 评论 -
unity3d gameframework 添加事件
定义public class EventGameCatFeed : MonoBehaviour{ // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { }}public sealed class EventGameCa原创 2022-03-13 10:06:44 · 4389 阅读 · 0 评论 -
unity ToggleGroup和Toggle.isOn的坑
发现有时,对Toggle.isOn进行赋值没有任何作用。找了半天原因,原来是已经绑定过toggle组件绑定的gameobject被删除后,它仍然会在togglegroup的列表中。解决办法:每次动态生成新的toggle时,也同时针对这组toggle新建一个toggleGroup,就可以解决这个问题。...原创 2022-03-12 20:47:33 · 6163 阅读 · 0 评论 -
gameframework 找到实体组中的所有entity
GameFramework.Entity.IEntityGroup cats_group = GameEntry.Entity.GetEntityGroup("实体组名称");var cats= cats_group.GetAllEntities();原创 2022-02-26 14:03:21 · 454 阅读 · 0 评论 -
GameFramework 框架 范例starforce学习 HPbar
在自定义这里建立一个节点,附上组件 HPBarComponent该脚本继承自被调用该脚本被调用时是这样被调用的(游戏内作为可打击对象的entity都有这个方法):比如在受伤时,出现一个ShowHPBar,方法就写在这个脚本里该脚本维护着一个HpBarItem组成的表这里表示如果已经生成过,则读取即可,如果未生成过,则进行生成。用到了其对象池的功能以下这几行完成了创建和父物体绑定 hpBarItem = I...原创 2022-01-28 16:13:13 · 907 阅读 · 0 评论 -
CS0117: ‘SpriteRendererDataAccessExtensions‘ SetBatchDeformableBufferAndLocalAABBArray
error CS0117: 'SpriteRendererDataAccessExtensions' does not contain a definition for 'SetBatchDeformableBufferAndLocalAABBArray'原创 2022-01-17 12:40:13 · 654 阅读 · 0 评论 -
unity gameframework学习 2d 相机跟随 范围限制 缩小放大
需要安装一下cinemachine插件using Cinemachine;using System.Collections;using System.Collections.Generic;using UnityEngine;/// <summary>/// 用于控制anchor的位置/// </summary>public class CameraNew : MonoBehaviour{ public Transform upleft; pu原创 2022-01-12 13:35:46 · 2797 阅读 · 0 评论 -
unity framework 学习 本地化赋值
confirmText = GameEntry.Localization.GetString("Dialog.ConfirmButton");原创 2022-01-06 21:09:16 · 2638 阅读 · 0 评论 -
unity gameframework 《starforce》 DialogForm UI学习
DialogForm的和其他界面一样,继承自UGuiForm比起普通的界面,自己实现了这些功能(可在创建时配置的):1.m_DialogMode2.m_PauseGame:是否暂停界面,如果为true,在onopen(OnOpen是每次打开是调用)时就会调用一次 GameEntry.Base.PauseGame(): public void PauseGame() { if (IsGamePaused) {原创 2022-01-06 21:04:50 · 2458 阅读 · 0 评论 -
unity gameframework starforce学习1
TargetableObject是可当作目标物entity的逻辑脚本都要继承的脚本实现接口:OnInit OnShow OnUpdate OnDead:GameEntry.Entity.HideEntity(this); OnTriggerEnter:计算伤害自己的函数 public void ApplyDamage(Entity attacker, int damageHP) { float fromHPRatio = m_原创 2022-01-04 14:16:34 · 997 阅读 · 0 评论 -
gameframework中的Component 模块功能
在GameMain命名空间中建立一个继承自GFComponent的你自己的Component 在GameEntry中可以添加这个属性{get;set},并在初始化Component时也初始化自己比如:在gameframework中的示例starforce中,可以学习HPBar的配置:在GameEntry中加入属性:public partial class GameEntry : MonoBehaviour { public static BuiltinDataCompo原创 2022-01-03 13:13:18 · 800 阅读 · 0 评论 -
unity GameFrameWork 储存数据 setting模块
变化首先,在UI层面玩家做一些操作时,会使得某些模块的数据产生变化,比如设置模块: public void OnMusicMuteChanged(bool isOn) { GameEntry.Sound.Mute("Music", !isOn); m_MusicVolumeSlider.gameObject.SetActive(isOn); }在对应的声音模块有两个:1个是SoundExtens...原创 2022-01-02 22:09:25 · 1019 阅读 · 0 评论 -
unity 点击悬停放大
using UnityEngine;using System.Collections;using DG.Tweening;public class HoverPreview: MonoBehaviour{ // PUBLIC FIELDS public GameObject TurnThisOffWhenPreviewing; // if this is null, will not turn off anything public Vector3 TargetPosi...原创 2021-09-30 21:47:24 · 985 阅读 · 0 评论 -
unity 自动排列间距
using UnityEngine;using System.Collections;// place first and last elements in children array manually// others will be placed automatically with equal distances between first and last elementspublic class SameDistanceChildren : MonoBehaviour { p..原创 2021-09-30 21:45:52 · 1035 阅读 · 0 评论 -
奇异推格子算法
这个奇异推格子和普通的推格子游戏的区别在于2点:1. 有些格子是连在一起的家具块。这些家具块如果连在一起(没有裂缝),则被推一个会整个被推。2. 格子有可能破裂。如果它的形变承受力较弱的话。这很好理解,就是指我们推一个塑料到一个墙上,塑料有可能就扁了。事先声明:想过很多自然界的模型,但与推格子的抽象程序不符合。1,2两点是模拟了我们推箱子中的两个自然情况:一是黏着的东西整体被推。二是东西也有可能被推碎了。只需要实现这两种情况即可,其他元素仍然是非常抽象的推箱子。算法示意原创 2021-09-25 21:54:57 · 697 阅读 · 0 评论 -
Dialogue System for Unity 学习2 用脚本创建数据库
本節包含有關在腳本中在運行時手動創建和添加其他對話數據庫的信息。請注意,除了手動創建數據庫內容外,您還可以在運行時導入 articy:draft XML 和 Chat Mapper XML。(請參閱導入和導出。)創建數據庫時,請使用 Template 類。如果腳本在編輯器中運行,您可以使用 TemplateTools.LoadFromEditorPrefs() 獲取模板類,該類使用您在對話編輯器的模板部分中設置的任何模板字段。否則使用 Template.FromDefault() 像下面的例子。..原创 2021-08-22 20:47:28 · 411 阅读 · 0 评论 -
Dialogue System for Unity 学习1
鼠标点击触发对话player 加selector,选择Select At 为mouse positionNPC加usable,选择max use distance 为30修改变量、条件原创 2021-08-19 22:30:02 · 319 阅读 · 0 评论 -
在Unity编辑器中显示中文字段
https://www.jianshu.com/p/e4f4faeb8455using UnityEngine;using System;using UnityEditor;[AttributeUsage(AttributeTargets.Field)]public class FieldLabelAttribute : PropertyAttribute{ public string label; public FieldLabelAttribute(string...原创 2021-06-21 17:11:31 · 424 阅读 · 0 评论 -
unity 走在地板上发出声音 环境音配置
放上以下脚本即可。public class Terrain_Sound_By_Distance : MonoBehaviour { // The sound clip to play when Colliding. public AudioClip soundClip; // The min and max pitch for when this sound is played. public float minPitch = 1; public float maxPitch = 1; .原创 2021-02-07 16:46:44 · 914 阅读 · 0 评论 -
unity 切换场景需要注意什么
如何触发切换场景。在地图上划定一个区域,在上面放上脚本,写上检测碰撞的tag,和目标场景的名称,还有转换的时间[RequireComponent (typeof (Collider2D))]public class Scene_Change : MonoBehaviour { // The tags that trigger the scene change. [Tooltip("The tags that trigger the scene change.")] public strin原创 2021-02-07 15:31:08 · 689 阅读 · 1 评论 -
unity 2D游戏实时检测渲染层级
public class Update_OrderInLayer_Moving : MonoBehaviour { private SpriteRenderer spriteRend; private Transform trans; void Start(){ spriteRend = GetComponent<SpriteRenderer> (); trans = GetComponent<Transform> (); spriteRend.sortingO原创 2021-02-07 13:09:05 · 256 阅读 · 0 评论 -
unity 利用PlayerPrefs进行保存save和读取load
一个类里面,需要保存的时候调用Save即可[Serializable]class Saved_Inventory{ public List<int> slotID = new List<int>(); public List<int> slotAmounts = new List<int>(); public int extraInventorySlots = 0;}public void Save(){ // Create a new原创 2021-02-06 21:34:03 · 1025 阅读 · 0 评论 -
unity 围绕圆心,取半径上一点
public Vector3 RandomCircle(Vector3 center, float radius){ float ang = UnityEngine.Random.Range(0, 360); Vector3 pos = Vector3.zero; pos.x = center.x + radius * Mathf.Cos (ang * Mathf.Deg2Rad); pos.y = center.y + radius * Mathf.Sin (ang * Mathf.Deg2Rad原创 2021-02-06 20:31:05 · 1007 阅读 · 0 评论 -
unity 移动UI
public class Move_GameObject : MonoBehaviour { [Tooltip("The start location of this gameobject.")] public Transform StartLocation; [Tooltip("The end location of this gameobject.")] public Transform EndLocation; private Transform _transform; void S原创 2021-02-06 19:03:25 · 1821 阅读 · 0 评论 -
unity常用参数及技巧
或许Input.mousePosition原创 2020-11-23 17:48:26 · 1243 阅读 · 1 评论