From 4e2231a92df7af15faa444410b929807b28dafa7 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Sun, 23 Sep 2018 15:12:59 +1000 Subject: [PATCH] Correct width calc on smaller width inspectors Correctly calc index in command menu popup when list is being filtered or reordered by the flowchart. --- Assets/Fungus/Scripts/Editor/BlockEditor.cs | 3 ++- .../PopupContent/CommandSelectorPopupWindowContent.cs | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index 8a1cc31a..5850dfd6 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -288,7 +288,8 @@ namespace Fungus.EditorUtils GUILayout.FlexibleSpace(); - var pos = EditorGUILayout.GetControlRect(true, 0, EditorStyles.objectField); + //using false to prevent forcing a longer row than will fit on smallest inspector + var pos = EditorGUILayout.GetControlRect(false, 0, EditorStyles.objectField); if (pos.x != 0) { lastCMDpopupPos = pos; diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs index 6e8fe765..ea3361ec 100644 --- a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs +++ b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs @@ -48,12 +48,11 @@ namespace Fungus.EditorUtils filteredAttributes = GetFilteredSupportedCommands(curBlock.GetFlowchart()); - int i = 0; foreach (var item in filteredAttributes) { - allItems.Add(new FilteredListItem(i, (item.Value.Category.Length > 0 ? item.Value.Category + CATEGORY_CHAR : "") + item.Value.CommandName, item.Value.HelpText)); - - i++; + //force lookup to orig index here to account for commmand lists being filtered by users + var newFilteredItem = new FilteredListItem(commandTypes.IndexOf(item.Key), (item.Value.Category.Length > 0 ? item.Value.Category + CATEGORY_CHAR : "") + item.Value.CommandName, item.Value.HelpText); + allItems.Add(newFilteredItem); } }