diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs index 5257ae44..3743293e 100644 --- a/Assets/Fungus/Scripts/Components/Flowchart.cs +++ b/Assets/Fungus/Scripts/Components/Flowchart.cs @@ -800,6 +800,23 @@ namespace Fungus return null; } + /// + /// Returns a list of variables matching the specified type. + /// + public virtual List GetVariables() where T: Variable + { + var varsFound = new List(); + + for (int i = 0; i < Variables.Count; i++) + { + var currentVar = Variables[i]; + if (currentVar is T) + varsFound.Add(currentVar as T); + } + + return varsFound; + } + /// /// Register a new variable with the Flowchart at runtime. /// The variable should be added as a component on the Flowchart game object.