随笔分类 - Unity / Unity-Editor
摘要:【需要注意的】 1) Text的默认Insepctor对应的类是UnityEditor.UI.TextEditor, 但是这个类我们无法直接访问, 只能通过反射的方式访问到 2) 使用[CustomEditor(typeof(Text))]并没有办法替换默认的Inspector, 所以只能通过继承T
阅读全文
摘要:# 默认的展示方式 # 自定义后的展示方式 # 标签类,enum成员加上这个标签才会按自定义的方式显示 public class CustomEnumAttribute : HeaderAttribute { public CustomEnumAttribute(string header) : b
阅读全文
摘要:# 最简单的就是,直接将anchor先设为center-mid,然后再设置位置大小 public static void SetAnchoredPos(RectTransform rtf, float x, float y) { var v2Mid = Vector2.one * 0.5f; rtf
阅读全文
摘要:#if UNITY_EDITOR using UnityEditor; public class MyToggleMenu { const string PrefsKey_IsAutoReloadXxx = "MyToggleMenu.IsAutoReloadXxx"; static int _is
阅读全文
摘要:# 展示最近打开的预制体历史 # 通过左右箭头就能快速打开最近打开过的预制体 public class AssetNavigateEditor : EditorWindow { [MenuItem("Window/MyTools/Prefab Open History", false, 1)] st
阅读全文
摘要:# 效果图 using System; using System.Reflection; using UnityEditor; using UnityEngine; #if UNITY_2019_1_OR_NEWER using UnityEngine.UIElements; #else using
阅读全文
摘要:# 展示TreeView的窗口 class SimpleTreeView2Window : EditorWindow { [MenuItem("TreeView Examples/Simple Tree View Window2")] static void ShowWindow() { var w
阅读全文
摘要:# 展示TreeView的窗口 class SimpleTreeViewWindow : EditorWindow { [MenuItem("TreeView Examples/Simple Tree View Window")] static void ShowWindow() { var win
阅读全文
摘要:# 展示表格的窗口 class TableViewWindow : EditorWindow { [MenuItem("TreeView Examples/Table View Window")] static void ShowWindow() { var window = GetWindow<T
阅读全文
摘要:【代码】 1 #if UNITY_EDITOR 2 3 using System.Collections.Generic; 4 using System.Reflection; 5 using UnityEngine; 6 using UnityEditor; 7 8 public class GU
阅读全文
摘要:1 #if UNITY_EDITOR 2 3 using System.Collections.Generic; 4 using System.Reflection; 5 using UnityEditor; 6 using UnityEngine; 7 8 [CustomEditor(typeof
阅读全文
摘要:TestAsset.cs 1 [CreateAssetMenu(menuName = "My/Test Asset")] 2 public class TestAsset : ScriptableObject 3 { 4 public List<TestAssetItem> list; 5 } Te
阅读全文
摘要:GUI.enabled的使用 1 public override void OnInspectorGUI() 2 { 3 GUILayout.Button("Button"); 4 EditorGUILayout.ToggleLeft("Toggle", true); 5 EditorGUILayo
阅读全文
摘要:1 private SearchField _searchField; 2 private string _searchText; 3 private ReorderableList _choicesList; 4 private List<string> _allListItems; 5 6 pu
阅读全文