From cdccb7cdffb6a38c082c75d4636904f62c57c2fd Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Sat, 19 Jun 2021 18:13:41 -0500 Subject: [PATCH] Updated adding command * Added the functionality so when a command is added, not only does it select it, it also scrolls to it. This is done pretty hackey, but it can work. --- Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs | 11 +++++++++++ .../PopupContent/CommandSelectorPopupWindowContent.cs | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs index 5c0a7f5d..b6ce2351 100644 --- a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs @@ -10,6 +10,12 @@ namespace Fungus.EditorUtils { public class CommandListAdaptor { + /// + /// If true, scrolls to the currently selected command in the inspector when the editor is redrawn. A + /// Automatically resets to false. + /// + public static bool ScrollToCommandOnDraw = false; + public void DrawCommandList() { if (summaryStyle == null) @@ -159,6 +165,11 @@ namespace Fungus.EditorUtils if (selectedCommand == command) { commandIsSelected = true; + if (ScrollToCommandOnDraw) + { + GUI.ScrollTo(position); + ScrollToCommandOnDraw = false; + } break; } } diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs index e00f4b74..d3a4d330 100644 --- a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs +++ b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs @@ -178,10 +178,10 @@ namespace Fungus.EditorUtils //clear commands just in case there was a selection made prior, // this way, only one command is selected at the end; the new one. - flowchart.ClearSelectedCommands(); - - flowchart.SelectedCommands.Add(newCommand); //select the new command. + flowchart.ClearSelectedCommands(); + CommandListAdaptor.ScrollToCommandOnDraw = true; + flowchart.AddSelectedCommand(newCommand); //select the new command. } } }