From b1d4aa54b7f55a9bd8df6dd07b503ea8972e2528 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Tue, 2 Sep 2014 15:15:16 +0100 Subject: [PATCH] Select category and command with a single popup --- .../FungusScript/Editor/FungusScriptEditor.cs | 46 +++--------------- .../FungusScript/Scripts/FungusScript.cs | 3 -- Assets/Shuttle/ShuttleGame.unity | Bin 116908 -> 117004 bytes 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs index 3e00bea6..d445eb59 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs @@ -114,39 +114,14 @@ namespace Fungus.Script GUILayout.Box("New Command", GUILayout.ExpandWidth(true)); - List categories = new List(); - - // Build list of categories - List subTypes = EditorExtensions.FindDerivedTypes(typeof(FungusCommand)).ToList(); - foreach(System.Type type in subTypes) - { - object[] attributes = type.GetCustomAttributes(false); - foreach (object obj in attributes) - { - CommandCategoryAttribute categoryAttr = obj as CommandCategoryAttribute; - if (categoryAttr != null) - { - if (!categories.Contains(categoryAttr.Category)) - { - categories.Add(categoryAttr.Category); - } - } - } - } - - categories.Sort(); - EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); - int selectedCategoryIndex = EditorGUILayout.Popup(fungusScript.selectedCategoryIndex, categories.ToArray()); - List commandNames = new List(); - List commandTypes = new List(); - - string categoryName = categories[selectedCategoryIndex]; - foreach (System.Type type in subTypes) + List commandTypes = EditorExtensions.FindDerivedTypes(typeof(FungusCommand)).ToList(); + + foreach (System.Type type in commandTypes) { object[] attributes = type.GetCustomAttributes(false); foreach (object obj in attributes) @@ -154,27 +129,18 @@ namespace Fungus.Script CommandCategoryAttribute categoryAttr = obj as CommandCategoryAttribute; if (categoryAttr != null) { - if (categoryAttr.Category == categoryName) - { - commandNames.Add(GetCommandName(type)); - commandTypes.Add(type); - } + string commandItem = categoryAttr.Category + " / " + GetCommandName(type); + commandNames.Add(commandItem); + break; } } } int selectedCommandIndex = EditorGUILayout.Popup(fungusScript.selectedCommandIndex, commandNames.ToArray()); - if (selectedCategoryIndex != fungusScript.selectedCategoryIndex) - { - // Default to first item in list if category has changed - selectedCommandIndex = 0; - } - if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(fungusScript, "Select Command"); - fungusScript.selectedCategoryIndex = selectedCategoryIndex; fungusScript.selectedCommandIndex = selectedCommandIndex; } diff --git a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs index 5e4addcc..e8e1dd1c 100644 --- a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs +++ b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs @@ -15,9 +15,6 @@ namespace Fungus.Script [System.NonSerialized] public FungusCommand copyCommand; - [HideInInspector] - public int selectedCategoryIndex; - [HideInInspector] public int selectedCommandIndex; diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index d149ef20d54770e33e86d3f7be04fbf42379998a..4aa2de9c26e9d7b5cdc68aabede6193a2f7dccea 100644 GIT binary patch delta 5929 zcmai&dvH@#9>>pxR$8DjebE$Xn?QlIrI40aT#Kd%ZVHwrP%wQ6Ezh#NQa~t(Hf2Qv z0tT-1WVPyLN1eF7+Cgod-DQgGXdO{f9~fsB2nbr%2ko*zWL5Ti+I#Cc{m0InHu-#i z`JUhTo!`0lrmr3xvhUCkJ&_8A5$S{BgpgRgHn!*wEIK-8&&Px1;L<4BT^1|9Ql^*p zmLTp$0XR&fy zd9pmhnk1huPn3+ZRGcd7Dn`q1)vu5bRAd|~St47KZf{Yq6Qr@d6{tTkR37aAV?^&7INc-pJ z=nk-`L4;f$+&7%JR^1k)okl5frUlva;R_*o!T6~bG!+i%23w;}!=_sZRz*!FSSYcC zGy#Rxu?UiFC?T`){ueddn2#G{ykNV*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