From 0fd7488dbc4b9c4d852197101ae726970724cf78 Mon Sep 17 00:00:00 2001 From: inarizushi Date: Sun, 24 Apr 2016 19:24:11 -0400 Subject: [PATCH] Add StopAllPlayCommand The StopAllPlayCommand is like the PlayCommand but will stop all other executing blocks first. --- Assets/Fungus/Flowchart/Editor/BlockEditor.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs index 31d91d37..675b3ae3 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs @@ -830,6 +830,7 @@ namespace Fungus if (showPlay) { commandMenu.AddItem(new GUIContent("Play from selected"), false, PlayCommand); + commandMenu.AddItem(new GUIContent("Stop all and play"), false, StopAllPlayCommand); } commandMenu.AddSeparator(""); @@ -1038,6 +1039,17 @@ namespace Fungus } } + protected void StopAllPlayCommand() + { + Block targetBlock = target as Block; + Flowchart flowchart = targetBlock.GetFlowchart(); + Command command = flowchart.selectedCommands[0]; + + // Stop all active blocks then run the selected block. + flowchart.StopAllBlocks(); + flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.commandIndex, 0.2f)); + } + protected IEnumerator RunBlock(Flowchart flowchart, Block targetBlock, int commandIndex, float delay) { yield return new WaitForSeconds(delay);