diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs index 14312634..bf4bae54 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs @@ -16,8 +16,11 @@ namespace Fungus { // Have we loaded the prefs yet private static bool prefsLoaded = false; + const string HIDE_MUSH_KEY = "hideMushroomInHierarchy"; + const string USE_EXP_MENUS = "useExperimentalMenus"; public static bool hideMushroomInHierarchy; + public static bool useExperimentalMenus; static FungusEditorPreferences() { @@ -36,17 +39,20 @@ namespace Fungus // Preferences GUI hideMushroomInHierarchy = EditorGUILayout.Toggle("Hide Mushroom Flowchart Icon", hideMushroomInHierarchy); + useExperimentalMenus = EditorGUILayout.Toggle(new GUIContent("Experimental Searchable Menus", "Experimental menus replace the Event, Add Variable and Add Command menus with a searchable menu more like the Unity AddComponent menu."), useExperimentalMenus); // Save the preferences if (GUI.changed) { - EditorPrefs.SetBool("hideMushroomInHierarchy", hideMushroomInHierarchy); + EditorPrefs.SetBool(HIDE_MUSH_KEY, hideMushroomInHierarchy); + EditorPrefs.SetBool(USE_EXP_MENUS, useExperimentalMenus); } } public static void LoadOnScriptLoad() { - hideMushroomInHierarchy = EditorPrefs.GetBool("hideMushroomInHierarchy", false); + hideMushroomInHierarchy = EditorPrefs.GetBool(HIDE_MUSH_KEY, false); + useExperimentalMenus = EditorPrefs.GetBool(USE_EXP_MENUS, false); prefsLoaded = true; } } diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs index c3ca20b8..6e8fe765 100644 --- a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs +++ b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs @@ -61,10 +61,18 @@ namespace Fungus.EditorUtils { curBlock = block; - var win = new CommandSelectorPopupWindowContent(currentHandlerName, - width, (int)(height - EditorGUIUtility.singleLineHeight * 3)); - PopupWindow.Show(position, win); + if (FungusEditorPreferences.useExperimentalMenus) + { + var win = new CommandSelectorPopupWindowContent(currentHandlerName, + width, (int)(height - EditorGUIUtility.singleLineHeight * 3)); + PopupWindow.Show(position, win); + } + else + { + //need to ensure we have filtered data + filteredAttributes = GetFilteredSupportedCommands(curBlock.GetFlowchart()); + } //old method DoOlderMenu(); diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs index d5c28624..b295f3a0 100644 --- a/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs +++ b/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs @@ -72,10 +72,12 @@ namespace Fungus.EditorUtils static public void DoEventHandlerPopUp(Rect position, string currentHandlerName, Block block, int width, int height) { - //new method - EventSelectorPopupWindowContent win = new EventSelectorPopupWindowContent(currentHandlerName, block, width, height); - PopupWindow.Show(position, win); - + if (FungusEditorPreferences.useExperimentalMenus) + { + //new method + EventSelectorPopupWindowContent win = new EventSelectorPopupWindowContent(currentHandlerName, block, width, height); + PopupWindow.Show(position, win); + } //old method DoOlderMenu(block); } diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs index 4a72e1d2..4e0d0384 100644 --- a/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs +++ b/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs @@ -56,10 +56,12 @@ namespace Fungus.EditorUtils static public void DoAddVariable(Rect position, string currentHandlerName, Flowchart flowchart) { curFlowchart = flowchart; - //new method - VariableSelectPopupWindowContent win = new VariableSelectPopupWindowContent(currentHandlerName, POPUP_WIDTH, POPUP_HEIGHT); - PopupWindow.Show(position, win); - + if (FungusEditorPreferences.useExperimentalMenus) + { + //new method + VariableSelectPopupWindowContent win = new VariableSelectPopupWindowContent(currentHandlerName, POPUP_WIDTH, POPUP_HEIGHT); + PopupWindow.Show(position, win); + } //old method DoOlderMenu(flowchart); }