记录一下在编写编辑器时对unity的一些操作限制,防止遗忘 static void OnHierarchyGUI(int instanceID, Rect selectionRect) { var e = UnityEngine.Event.current; //禁用 TBCParticleSystem 在Hierarchy面板的右键菜单 if (selectionRect.Contains(e.mousePosition) && e.button == 1 && e.type &l…
记录一下在编写编辑器时对unity的一些操作限制,防止遗忘 static void OnHierarchyGUI(int instanceID, Rect selectionRect) { var e = UnityEngine.Event.current; //禁用 TBCParticleSystem 在Hierarchy面板的右键菜单 if (selectionRect.Contains(e.mousePosition) && e.button == 1 && e.type &l…
using System.Collections; using System.Collections.Generic; using UnityEngine; namespace TBC { public class TBCGizmos { public enum CapsuleDirection { XAxis, YAxis, ZAxis, } /// <summary> /// 线框球体 /// </summary> public static void DrawWireSphere(Ma…
C#脚本 using UnityEngine; using UnityEditor; public class TestClass { // 要调用的函数 public static void TestFunc() { Debug.Log("************* TestFunc ******************"); startTime = Time.realtimeSinceStartup; EditorApplication.update += Run; } static float startTi…
最近在写一个基于Timeline的编辑器,需要在关闭Timeline编辑器的时候对TBCAsset(继承于TimelineAsset)资源进行保存,并写入一些额外的数据,因为保存有些耗时需要1~2秒,所以需要判定如果只是打开,但并未修改TBCAsset资源点关闭后直接退出 我用EditorUtility.IsDirty来对资源进行判断是否有修改,但发现并不准确,翻看Timeline源码后,发现TimelineAsset的TrackAsset与PlayableAsset资源是通过AssetDatabase.AddOb…
using System; using System.Reflection; class Program { // Methods to get: public void MethodA(int i, int j) { } public void MethodA(int[] i) { } public unsafe void MethodA(int* i) { } public void MethodA(ref int r) {} // Method that takes an out parameter. pub…
在编辑器下,做playable相关的操作,比如调用PlayableGrahp.Stop()后再执行PlayableGrahp.Play(),但是更新函数没有被调用 解决方法: 调用UnityEditor.EditorApplication.QueuePlayerLoopUpdate(); Normally, a player loop update will occur in the editor when the Scene has been modified. This method al…
Unity默认对List与Array的序列化,在Inspector面板上的显示,对操作并不是很友好,比如需要交换两个数组元素下标时,需要挨个赋值两个被交换的元素,当数组元素为复杂的类对象时,此操作更加麻烦,而Reorderable List可以更加直观的显示数组元素,整体上会更加美观,并且自带拖拽等操作,以下使用案例截取Cinemachine插件使用Reorderable List的部分代码 声明 private ReorderableList mWaypointList; 初始化 void SetupWaypoi…
GameObject sceneCameraGo = EditorUtility.CreateGameObjectWithHideFlags("SceneCamera", HideFlags.HideAndDontSave, typeof(Camera)); var sceneCamera = sceneCameraGo.GetComponent<Camera>();
最近希望在编辑器模式下通过GameView的鼠标操作镜头,所以首先需要获取到鼠标的操作事件 编辑器模式下运行一般来有监听EditorApplication.update回调,或者 在MonoBehaviour的类声明[ExecuteInEditMode]、[ExecuteAlways]标签两种方式。获取鼠标方式一般有Input和Event两种方式,下面直接说在编辑器模式下的组合结果 1.监听EditorApplication.update回调的方式: 无法使用Input(Input.touchCount…
先看一下最终效果 这是ProjectSetting窗口效果,我实际存储了TBCEditorSetting.asset这个资源的GUID,这里只是重写了GUI 数据存储在ProjectSettings/TBCFrameworkSettings.asset 这里要注意的是这个asset文件不在Assets文件夹下,所以不能使用AssetDatabase来加载,需要使用InternalEditorUtility的LoadSerializedFileAndForget与SaveToSerializedFileAndForg…