diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index 6efe4cfa..fa83b205 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -251,23 +251,38 @@ namespace Fungus return b; } + /** + * Returns the named Block in the flowchart, or null if not found. + */ + public virtual Block FindBlock(string blockName) + { + Block [] blocks = GetComponentsInChildren(); + foreach (Block block in blocks) + { + if (block.blockName == blockName) + { + return block; + } + } + + return null; + } + /** * Start running another Flowchart by executing a specific child block. * The block must be in an idle state to be executed. - * Returns true if the Block started execution. + * You can use this method in a UI event. e.g. to handle a button click. */ - public virtual bool ExecuteBlock(string blockName) + public virtual void ExecuteBlock(string blockName) { Block [] blocks = GetComponentsInChildren(); foreach (Block block in blocks) { if (block.blockName == blockName) { - return ExecuteBlock(block); + ExecuteBlock(block); } } - - return false; } /**