InMemoryVariableStorage
public class InMemoryVariableStorage : VariableStorageBehaviour, IEnumerable<KeyValuePair<string, object>>Inherits from Yarn.Unity.VariableStorageBehaviour
Implements Yarn.IVariableStorage, Yarn.IVariableAccess, System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.Object}}, System.Collections.IEnumerable
This class stores variables in memory, and is erased when the game exits.
This class also has basic serialization and save/load example functions.
You can also enumerate over the variables by using a foreach
loop:
// 'storage' is an InMemoryVariableStorage
foreach (var variable in storage) {
string name = variable.Key;
System.Object value = variable.Value;
}
#Fields
#showDebug
public bool showDebug;Type Boolean
#Methods
#Clear()
public override void Clear()#Contains(string)
public override bool Contains(string variableName)Parameters
variableNamestring
Returns Boolean
#GetAllVariables()
public override (Dictionary<string, float>, Dictionary<string, string>, Dictionary<string, bool>) GetAllVariables()Returns ValueTuple
#GetDebugList()
public string GetDebugList()Returns String
#SetAllVariables(Dictionary<string, float>, Dictionary<string, string>, Dictionary<string, bool>, bool)
public override void SetAllVariables(Dictionary<string, float> floats, Dictionary<string, string> strings, Dictionary<string, bool> 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 override void SetValue(string variableName, bool boolValue)Parameters
variableNamestringthe name of the variableboolValueboolthe new value
#SetValue(string, float)
public override void SetValue(string variableName, float floatValue)Parameters
variableNamestringthe name of the variablefloatValuefloatthe new value
#SetValue(string, string)
public override void SetValue(string variableName, string stringValue)Parameters
variableNamestringthe name of the variablestringValuestringthe new value
#TryGetValue<T>(string, T)
public override bool TryGetValue<T>(string variableName, [NotNullWhen(true)] out T result)Parameters
variableNamestringresultT
Returns Boolean
Generated from Yarn Spinner for Unity 3.3.