From c37ada3da526ea14719b97b2b5e3bb7e8ffafa04 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 3 Sep 2014 00:02:51 +0100 Subject: [PATCH] Reverted to 2 popup method for Add Command --- .../FungusScript/Editor/SequenceEditor.cs | 64 ++++++++++++++---- .../FungusScript/Scripts/FungusScript.cs | 3 + Assets/Shuttle/ShuttleGame.unity | Bin 117228 -> 118492 bytes 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs index cd995e6a..8423c8e6 100644 --- a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs @@ -42,7 +42,6 @@ namespace Fungus.Script Undo.RecordObject(sequence, "Set Sequence Description"); sequence.description = desc; } - ReorderableListGUI.Title("Command Sequence"); @@ -57,14 +56,37 @@ namespace Fungus.Script EditorGUI.BeginChangeCheck(); - EditorGUILayout.Separator(); - EditorGUILayout.BeginHorizontal(); + + // Build list of categories + List categories = new List(); + 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(); + + GUILayout.Label("New Command"); + GUILayout.FlexibleSpace(); + int selectedCategoryIndex = EditorGUILayout.Popup(fungusScript.selectedCommandCategoryIndex, categories.ToArray()); List commandNames = new List(); - List commandTypes = EditorExtensions.FindDerivedTypes(typeof(FungusCommand)).ToList(); + List commandTypes = new List(); - foreach (System.Type type in commandTypes) + string categoryName = categories[selectedCategoryIndex]; + foreach (System.Type type in subTypes) { object[] attributes = type.GetCustomAttributes(false); foreach (object obj in attributes) @@ -72,24 +94,33 @@ namespace Fungus.Script CommandCategoryAttribute categoryAttr = obj as CommandCategoryAttribute; if (categoryAttr != null) { - string commandItem = categoryAttr.Category + " - " + FungusScriptEditor.GetCommandName(type); - commandNames.Add(commandItem); - break; + if (categoryAttr.Category == categoryName) + { + commandNames.Add(FungusScriptEditor.GetCommandName(type)); + commandTypes.Add(type); + } } } } - - int selectedCommandIndex = EditorGUILayout.Popup(fungusScript.selectedAddCommandIndex, commandNames.ToArray()); + int selectedCommandIndex = EditorGUILayout.Popup(fungusScript.selectedAddCommandIndex, commandNames.ToArray()); + if (selectedCategoryIndex != fungusScript.selectedCommandCategoryIndex) + { + // Default to first item in list if category has changed + selectedCommandIndex = 0; + } + + EditorGUILayout.EndHorizontal(); + if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(fungusScript, "Select Command"); + fungusScript.selectedCommandCategoryIndex = selectedCategoryIndex; fungusScript.selectedAddCommandIndex = selectedCommandIndex; } if (selectedCommandIndex >= commandTypes.Count) { - EditorGUILayout.EndHorizontal(); return; } @@ -97,11 +128,14 @@ namespace Fungus.Script if (fungusScript.selectedSequence == null || selectedType == null) { - EditorGUILayout.EndHorizontal(); return; } - - if (GUILayout.Button(new GUIContent("Add Command", "Add the selected command to the sequence"), EditorStyles.miniButton)) + + EditorGUILayout.BeginHorizontal(); + + GUILayout.FlexibleSpace(); + + if (GUILayout.Button(new GUIContent("Add Command", "Add the selected command to the sequence"))) { FungusCommand newCommand = Undo.AddComponent(fungusScript.selectedSequence.gameObject, selectedType) as FungusCommand; Undo.RecordObject(fungusScript, "Add Command"); @@ -110,7 +144,7 @@ namespace Fungus.Script if (fungusScript.copyCommand != null) { - if (GUILayout.Button("Paste", EditorStyles.miniButton)) + if (GUILayout.Button("Paste")) { FungusCommandEditor.PasteCommand(fungusScript.copyCommand, fungusScript.selectedSequence); } diff --git a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs index cd63a7c3..ab827202 100644 --- a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs +++ b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs @@ -18,6 +18,9 @@ namespace Fungus.Script [HideInInspector] public int selectedAddCommandIndex; + [HideInInspector] + public int selectedCommandCategoryIndex; + [HideInInspector] public Vector2 scriptScrollPos; diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index eefa97b1857e436c5c39452c9c1f452fa353da2d..95bedfde114bc22cea730b0b17a1ba4ece65e981 100644 GIT binary patch delta 5340 zcmZwL3s6&68VB%mYSd^grUl%fAW^hNQH$@i;2Oc&pdybdhKCXmBr0HdjK*i8RbjV^ zX)kcmx{4ijoN2ooS7*b_Rwvc%nw@1^cH3^*86UA##9do)SFNoN_J5Ll!?~F<+{w)^ z-*?{U z&5sn8eW(%KJBA9w5{3$O`7a446IKa2uUd#mPz(3-qv?3zdh9sS{5*X@=xv-Vw3Q4K zl8+4$wiQHCec+{kv6s#*)r!y9&C|%iLVU&`;eNp{XreIR6)D6QM$^f{2Rjq!6yfuo zIyzN2wj)M3S)v(QT3lC5)ac7AtRUfGVHCRlBAv#1cIMM6-D#TX>5iuphB$6IEfe)g zgsep{m9B1BE6k4P5BvK1YVddqrkO^_GTc9stOsV5j13&SR@gify|7~3%jKD2`ssue zN--=h57sc9ILKi61&3U7Q>QeD&szB^d~mJ z%DD0_zbWrg1x&4G|y5d-|)?z?1u4;xd~IxR>n0&WG7i*e2<%9KG;4~;+L)# zn0XE%OYr=^Qiu0ATCPk#1>}?W!ZZeDay_gK#wS18Jz_>LY&i;)hx$jD>D6HG@Ys=%3;T$l+Ligjt%$c>E|f}{|0ly_}=B^rW?Cp{LaaTnT&)S$4L35 zs{qyuv*Gy@X;cegmiZV}2T&f?o%;*ZoIt*XyI@@~zT%JnVtzd-m5`OlmFN8&%mrgx z_DktH4^yWpx82pV=S^0aT!(`da1H1M@|CQ~d@o(Q09)=kLT(QTUi*JInXX%?thf>8 zgz>otU|ldP%0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