From c846d45d0cde59c4b11631ccf115f9e4455b09a2 Mon Sep 17 00:00:00 2001 From: Inari Zushi Date: Thu, 21 Apr 2016 18:45:38 -0400 Subject: [PATCH] Add Block and command switching during playback --- Assets/Fungus/Flowchart/Editor/BlockEditor.cs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs index a1d3a856..dbf1a57c 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs @@ -797,7 +797,7 @@ namespace Fungus showCut = true; showCopy = true; showDelete = true; - if (flowchart.selectedCommands.Count == 1) + if (flowchart.selectedCommands.Count == 1 && Application.isPlaying) { showPlay = true; } @@ -859,7 +859,7 @@ namespace Fungus commandMenu.AddDisabledItem(new GUIContent("Play from Selected Command")); } - commandMenu.AddSeparator(""); + commandMenu.AddSeparator(""); commandMenu.AddItem (new GUIContent ("Select All"), false, SelectAll); commandMenu.AddItem (new GUIContent ("Select None"), false, SelectNone); @@ -1047,10 +1047,23 @@ namespace Fungus protected void PlayCommand() { - Block block = target as Block; - Flowchart flowchart = block.GetFlowchart(); + Block targetBlock = target as Block; + Flowchart flowchart = targetBlock.GetFlowchart(); Command command = flowchart.selectedCommands[0]; - //block.Execute(null, command.commandIndex); + targetBlock.jumpToCommandIndex = command.commandIndex; + if (!targetBlock.IsExecuting()) + { + Block[] blocks = flowchart.GetComponentsInChildren(true); + foreach (Block b in blocks) + { + if (b.IsExecuting()) + { + b.Stop(); + } + } + flowchart.ExecuteBlock(targetBlock.blockName); + } + } protected void SelectPrevious()