MemoryVariableStore
A simple concrete implementation of IVariableStorage
that keeps all variables in memory.
public class MemoryVariableStore : IVariableStorageInherits from System.Object
Implements Yarn.IVariableStorage, Yarn.IVariableAccess
#Properties
#Program
Gets or sets the Yarn Program that stores information
about the initial values of variables, and is able to produce values
for smart variables.
public Program? Program { get; set; }Type Program
#SmartVariableEvaluator
Gets or sets the object to use when evaluating smart variables.
public ISmartVariableEvaluator? SmartVariableEvaluator { get; set; }#Methods
#Clear()
Removes all variables from storage.
public void Clear()#GetVariableKind(string)
Gets the kind of variable named
name.public VariableKind GetVariableKind(string name)Parameters
namestringThe name of the variable.
Returns VariableKind: A VariableKind enum representing the kind of
the variable named name.
#SetValue(string, bool)
Stores a
bool in this VariableStorage.public virtual void SetValue(string variableName, bool boolValue)Parameters
variableNamestringThe name to associate with this variable.boolValueboolThe boolean value to store.
#SetValue(string, float)
Stores a
float in this VariableStorage.public virtual void SetValue(string variableName, float floatValue)Parameters
variableNamestringThe name to associate with this variable.floatValuefloatThe number to store.
#SetValue(string, string)
Stores a
string in this VariableStorage.public virtual void SetValue(string variableName, string stringValue)Parameters
variableNamestringThe name to associate with this variable.stringValuestringThe string to store.
#TryGetValue<T>(string, T?)
Given a variable name, attempts to fetch a value for the variable,
either from storage, initial values found in Program,
or by evaluating a smart variable found in Program.
public virtual bool TryGetValue<T>(string variableName, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? result)Type Parameters
TThe type of the value to return. The fetched value will be converted to this type, if possible.
Parameters
variableNamestringThe name of the variable.resultTIf this method returnstrue, this parameter will contain the fetched value.
Returns Boolean: true if a value could be fetched; false otherwise.
Generated from Yarn Spinner for Unity 3.3.