Browse Source

Change #70 Added FungusScript.GetVariable() method

master
chrisgregan 10 years ago
parent
commit
b24197beec
  1. 19
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs

19
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -265,6 +265,25 @@ namespace Fungus
}
}
/**
* Returns the variable with the specified key, or null if the key is not found.
* You can then access the variable's value using the Value property. e.g.
* BooleanVariable boolVar = fungusScript.GetVariable<BooleanVariable>("MyBool");
* boolVar.Value = false;
*/
public T GetVariable<T>(string key) where T : Variable
{
foreach (Variable variable in variables)
{
if (variable.key == key)
{
return variable as T;
}
}
return null;
}
/**
* Gets a list of all variables with public scope in this Fungus Script.
*/

Loading…
Cancel
Save