EditorWindow类的OnGUI函数只会在窗口焦点处于Editor窗口上的时候才会运行.如果希望焦点不在Editor窗口上的时候,它也能实时更新,可以实现以下方法: OnDestroy OnDestroy is called when the EditorWindow is closed. OnFocus Called when the window gets keyboard focus. OnGUI Implement your own editor GUI here. OnHiera
在开发游戏中,为了减少不必要的代码量,我们经常会继承MonoBehaviour,那么MonoBehaviour内部的内置方法Start.Update等等如果在父类中定义了,在子类中再次定义会发生什么事呢? 我们来看看几个示例: using UnityEngine; using System.Collections; public class Test1 : MonoBehaviour { void Start() { Debug.Log("Test1 Start"); } void U
单例模式是设计模式中最为常见的,不多解释了.但应该尽量避免使用,一般全局管理类才使用单例. 普通泛型单例: public abstract class Singleton<T> where T : class, new() { private static T instance = null; private static readonly object locker = new object(); public static T Instance { get { lock (locker)
在我们做项目的过程中 经常会有预设中出现空的脚本 例如: 导致的原因是因为 脚本的丢失 现在我们来做一个检查工程中有空脚本的预设工具 老规矩直接上代码 放到工程就能用 using UnityEngine; using UnityEditor; using System.IO; using System.Collections.Generic; public class PrefabTool : EditorWindow { [MenuItem("Prefab Tool/Check Missing