├── CodeGen ├── CodeGenWindow.cs └── CodeGenWindow.cs.meta ├── Demo ├── Demo.unity ├── Demo.unity.meta ├── NewBehaviourScript.cs └── NewBehaviourScript.cs.meta ├── README.md └── Rotorz ├── Element Adder Menu.meta ├── Element Adder Menu ├── ElementAdderMenuBuilder.cs ├── ElementAdderMenuBuilder.cs.meta ├── ElementAdderMenuCommandAttribute.cs ├── ElementAdderMenuCommandAttribute.cs.meta ├── ElementAdderMeta.cs ├── ElementAdderMeta.cs.meta ├── GenericElementAdderMenu.cs ├── GenericElementAdderMenu.cs.meta ├── GenericElementAdderMenuBuilder.cs ├── GenericElementAdderMenuBuilder.cs.meta ├── IElementAdder.cs ├── IElementAdder.cs.meta ├── IElementAdderMenu.cs ├── IElementAdderMenu.cs.meta ├── IElementAdderMenuBuilder.cs ├── IElementAdderMenuBuilder.cs.meta ├── IElementAdderMenuCommand.cs └── IElementAdderMenuCommand.cs.meta ├── GenericListAdaptor.cs ├── GenericListAdaptor.cs.meta ├── IReorderableListAdaptor.cs ├── IReorderableListAdaptor.cs.meta ├── IReorderableListDropTarget.cs ├── IReorderableListDropTarget.cs.meta ├── Internal.meta ├── Internal ├── GUIHelper.cs ├── GUIHelper.cs.meta ├── ReorderableListResources.cs ├── ReorderableListResources.cs.meta ├── SerializedPropertyUtility.cs └── SerializedPropertyUtility.cs.meta ├── ReorderableListControl.cs ├── ReorderableListControl.cs.meta ├── ReorderableListEvents.cs ├── ReorderableListEvents.cs.meta ├── ReorderableListFlags.cs ├── ReorderableListFlags.cs.meta ├── ReorderableListGUI.cs ├── ReorderableListGUI.cs.meta ├── ReorderableListStyles.cs ├── ReorderableListStyles.cs.meta ├── SerializedPropertyAdaptor.cs └── SerializedPropertyAdaptor.cs.meta /CodeGen/CodeGenWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using UnityEngine.Events; 4 | using System.Collections.Generic; 5 | using UnityEditor; 6 | using Rotorz.ReorderableList; 7 | using System; 8 | using Object = UnityEngine.Object; 9 | using System.Reflection; 10 | public class CodeGenWindow : EditorWindow 11 | { 12 | [MenuItem("Window/CodeGen")] 13 | private static void Open() 14 | { 15 | window = GetWindow(); 16 | } 17 | static CodeGenWindow window; 18 | private SerializedProperty script; 19 | private SerializedObject serializedObj; 20 | private List graphics = new List(); 21 | private List selectables = new List(); 22 | private GameObject parent; 23 | private GameObject target; 24 | private List scripts; 25 | private bool[] scriptgroup; 26 | private List _selectedScript; 27 | private List Selected 28 | { 29 | get 30 | { 31 | if (_selectedScript == null) 32 | { 33 | _selectedScript = new List(); 34 | } 35 | else 36 | { 37 | _selectedScript.Clear(); 38 | } 39 | if (scripts != null && scriptgroup != null && scripts.Count == scriptgroup.Length) 40 | { 41 | for (int i = 0; i < scriptgroup.Length; i++) 42 | { 43 | if (scriptgroup[i]) 44 | { 45 | _selectedScript.Add(scripts[i]); 46 | } 47 | } 48 | } 49 | return _selectedScript; 50 | } 51 | } 52 | 53 | private string imgFormat = "\t[SerializeField] private Image m_{0}; \n"; 54 | private string rawimgFormat = "\t[SerializeField] private RawImage m_{0}; \n"; 55 | private string txtFormat = "\t[SerializeField] private Text m_{0}; \n"; 56 | 57 | private string btnFormat = "\t[SerializeField] private Button m_{0}; \n"; 58 | private string togFormat = "\t[SerializeField] private Toggle m_{0}; \n"; 59 | private string inptFormat = "\t[SerializeField] private InputField m_{0}; \n"; 60 | private string slidFormat = "\t[SerializeField] private Slider m_{0}; \n"; 61 | 62 | private string onClickFormat = "\t\tm_{0}.onClick.AddListener(On{1}Clicked); \n"; 63 | private string onValueChangeFormat = "\t\tm_{0}.onValueChanged.AddListener(On{1}ValueChanged); \n"; 64 | 65 | private string btnFuncFormat = "\tprivate void On{0}Clicked()\n\t{\n\t}\n"; 66 | private string togFuncFormat = "\tprivate void On{0}ValueChanged(bool arg)\n\t{\n\t}\n"; 67 | private string inputFuncFormat = "\tprivate void On{0}ValueChanged(string arg)\n\t{\n\t\t\n\t}\n"; 68 | private string sliderFuncFormat = "\tprivate void On{0}ValueChanged(float arg)\n\t{\n\t\t\n\t}\n"; 69 | 70 | private Vector2 scrollPos; 71 | private void OnEnable() 72 | { 73 | serializedObj = new SerializedObject(this); 74 | script = serializedObj.FindProperty("m_Script"); 75 | } 76 | void OnGUI() 77 | { 78 | serializedObj.Update(); 79 | if (window == null) window = GetWindow(); 80 | EditorGUILayout.PropertyField(script); 81 | using (var h = new EditorGUILayout.HorizontalScope()) 82 | { 83 | using (var v = new EditorGUILayout.VerticalScope(GUILayout.Width(window.position.width * 0.3f))) 84 | { 85 | GUI.backgroundColor = Color.green; 86 | var rect = v.rect; 87 | rect.height = window.position.height - EditorGUIUtility.singleLineHeight; 88 | GUI.Box(rect, ""); 89 | GUI.backgroundColor = Color.white; 90 | DrawAutoImport(); 91 | DrawGraphis(); 92 | DrawSelectables(); 93 | } 94 | using (var v = new EditorGUILayout.VerticalScope(GUILayout.Width(window.position.width * 0.7f))) 95 | { 96 | DrawObjectItem(); 97 | DrawToolButtons(); 98 | } 99 | } 100 | serializedObj.ApplyModifiedProperties(); 101 | } 102 | 103 | private void DrawAutoImport() 104 | { 105 | using (var h = new EditorGUILayout.HorizontalScope()) 106 | { 107 | var rect = h.rect; 108 | rect.width /= 3f; 109 | rect.height = EditorGUIUtility.singleLineHeight; 110 | parent = EditorGUI.ObjectField(rect, parent, typeof(GameObject), true) as GameObject; 111 | rect.x += rect.width; 112 | rect.width /= 2f; 113 | if (GUI.Button(rect, "btn")) 114 | { 115 | if (parent == null) return; 116 | Recursive(parent.transform, (tran) => 117 | { 118 | Button obj = tran.GetComponent