Browse Source

Merge pull request #461 from inarizushi/bugfix/playcommand

Stop all executing blocks on play selected
master
Chris Gregan 9 years ago
parent
commit
c9c32152d7
  1. 12
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs

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

Loading…
Cancel
Save