VariableStorageBehaviour
MonoBehaviour that a DialogueRunner uses
to store and retrieve variables.public abstract class VariableStorageBehaviour : MonoBehaviour, Yarn.IVariableStorageInherits from MonoBehaviour
Implements Yarn.IVariableStorage, Yarn.IVariableAccess
MonoBehaviour, which
means that subclasses of this class can be attached to GameObjects.#Properties
#Program
public Program? Program { get; set; }Type Program
#SmartVariableEvaluator
public ISmartVariableEvaluator? SmartVariableEvaluator { get; set; }#Methods
#AddChangeListener(System.Action<string, object>)
public IDisposable AddChangeListener(System.Action<string, object> onChange)Parameters
onChangeAction<string, object>The delegate to run when the variable changes value.
Returns IDisposable: An System.IDisposable that removes the registration
when its System.IDisposable.Dispose method is
called.
#AddChangeListener<T>(string, Action<T>)
variableName is modified.public IDisposable AddChangeListener<T>(string variableName, Action<T> onChange)Type Parameters
TThe type of the variable.
Parameters
variableNamestringThe name of the variable to watch for changes to. This variable must be of typeT, and it must not be a smart variable.onChangeAction<T>The delegate to run when the variable changes value.
Returns IDisposable: An System.IDisposable that removes the registration
when its System.IDisposable.Dispose method is
called.
Exceptions
System.InvalidOperationExceptionCalled when Program is not set.System.ArgumentExceptionCalled whenvariableNameis not the name of a valid variable, or ifTdoes not match the type of the variable.
#Clear()
public abstract void Clear();#Contains(string)
public abstract bool Contains(string variableName);Parameters
variableNamestringThe name of the variable to check for.
Returns Boolean: true if this variable storage contains a
value for the variable named variableName; false otherwise.
#GetAllVariables()
public abstract (FloatDictionary FloatVariables, StringDictionary StringVariables, BoolDictionary BoolVariables) GetAllVariables();Returns ValueTuple
#GetVariableKind(string)
#SetAllVariables(FloatDictionary, StringDictionary, BoolDictionary, bool)
public abstract void SetAllVariables(FloatDictionary floats, StringDictionary strings, BoolDictionary bools, bool clear = true);Parameters
clearboolShould the load also wipe the storage. Defaults to true so all existing variables will be cleared.floatsDictionary<string, float>stringsDictionary<string, string>boolsDictionary<string, bool>
#SetValue(string, bool)
public abstract void SetValue(string variableName, bool boolValue);Parameters
variableNamestringboolValuebool
#SetValue(string, float)
public abstract void SetValue(string variableName, float floatValue);Parameters
variableNamestringfloatValuefloat
#SetValue(string, string)
public abstract void SetValue(string variableName, string stringValue);Parameters
variableNamestringstringValuestring
#TryGetValue<T>(string, T?)
public abstract bool TryGetValue<T>(string variableName, [NotNullWhen(true)] out T? result);Parameters
variableNamestringresultT
Returns Boolean
Generated from Yarn Spinner for Unity 3.3.