From 05bf42fdd75dd12736f86a9c53c0e3425cc0cdfb Mon Sep 17 00:00:00 2001 From: Christopher Date: Wed, 26 Apr 2017 21:15:37 +0100 Subject: [PATCH] Stop a named Block in a Flowchart --- Assets/Fungus/Scripts/Components/Flowchart.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs index 1c1224d4..dd717230 100644 --- a/Assets/Fungus/Scripts/Components/Flowchart.cs +++ b/Assets/Fungus/Scripts/Components/Flowchart.cs @@ -491,6 +491,25 @@ namespace Fungus Debug.LogWarning("Block " + blockName + "failed to execute"); } } + + /// + /// Stops an executing Block in the Flowchart. + /// + public virtual void StopBlock(string blockName) + { + var block = FindBlock(blockName); + + if (block == null) + { + Debug.LogError("Block " + blockName + "does not exist"); + return; + } + + if (block.IsExecuting()) + { + block.Stop(); + } + } /// /// Execute a child block in the flowchart.