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);