Browse Source

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.
master
Michael Cox 3 years ago committed by Steve Halliwell
parent
commit
cdccb7cdff
  1. 11
      Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs
  2. 4
      Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs

11
Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs

@ -10,6 +10,12 @@ namespace Fungus.EditorUtils
{ {
public class CommandListAdaptor public class CommandListAdaptor
{ {
/// <summary>
/// If true, scrolls to the currently selected command in the inspector when the editor is redrawn. A
/// Automatically resets to false.
/// </summary>
public static bool ScrollToCommandOnDraw = false;
public void DrawCommandList() public void DrawCommandList()
{ {
if (summaryStyle == null) if (summaryStyle == null)
@ -159,6 +165,11 @@ namespace Fungus.EditorUtils
if (selectedCommand == command) if (selectedCommand == command)
{ {
commandIsSelected = true; commandIsSelected = true;
if (ScrollToCommandOnDraw)
{
GUI.ScrollTo(position);
ScrollToCommandOnDraw = false;
}
break; break;
} }
} }

4
Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs

@ -180,8 +180,8 @@ namespace Fungus.EditorUtils
// this way, only one command is selected at the end; the new one. // this way, only one command is selected at the end; the new one.
flowchart.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
flowchart.SelectedCommands.Add(newCommand); //select the new command. CommandListAdaptor.ScrollToCommandOnDraw = true;
flowchart.AddSelectedCommand(newCommand); //select the new command.
} }
} }
} }

Loading…
Cancel
Save