diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs index 631d19ac..d56aae2e 100644 --- a/Assets/Fungus/Scripts/Components/Flowchart.cs +++ b/Assets/Fungus/Scripts/Components/Flowchart.cs @@ -482,6 +482,31 @@ namespace Fungus return null; } + /// + /// Checks availability of the block in the Flowchart. + /// You can use this method in a UI event. e.g. to test availability block, before handle it. + public virtual bool HasBlock(string blockName) + { + var block = FindBlock(blockName); + return block != null; + } + + /// + /// Executes the block if it is available in the Flowchart. + /// You can use this method in a UI event. e.g. to try executing block without confidence in its existence. + public virtual bool ExecuteIfHasBlock(string blockName) + { + if (HasBlock(blockName)) + { + ExecuteBlock(blockName); + return true; + } + else + { + return false; + } + } + /// /// Execute a child block in the Flowchart. /// You can use this method in a UI event. e.g. to handle a button click.