Pardon our dust! Docs for Yarn Spinner for Unity 3.2 and Yarn Spinner for Godot C# are on docs.yarnspinner.dev (the old docs site). Docs for Yarn Spinner for Unity 3.3 (pre-release, out ASAP), Yarn Spinner for Godot GDScript and Yarn Spinner for Unreal Engine (work in progress) are on /docs/ (the new docs site).

InMemoryVariableStorage

A simple implementation of VariableStorageBehaviour.
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()

Removes all variables from storage.
public override void Clear()

#Contains(string)

returns a boolean value representing if the particular variable is inside the variable storage
public override bool Contains(string variableName)

Parameters

  • variableNamestring

Returns Boolean

#GetAllVariables()

Provides a unified interface for exporting all variables. Intended to be a point for custom saving, editors, etc.
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)

Provides a unified interface for loading many variables all at once. Will override anything already in the variable storage.
public override void SetAllVariables(Dictionary<string, float> floats, Dictionary<string, string> strings, Dictionary<string, bool> bools, bool clear = true)

Parameters

  • clearbool
    Should 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)

Sets the requested variable to have the supplied bool value
public override void SetValue(string variableName, bool boolValue)

Parameters

  • variableNamestring
    the name of the variable
  • boolValuebool
    the new value

#SetValue(string, float)

Sets the requested variable to have the supplied float value
public override void SetValue(string variableName, float floatValue)

Parameters

  • variableNamestring
    the name of the variable
  • floatValuefloat
    the new value

#SetValue(string, string)

Sets the requested variable to have the supplied string value
public override void SetValue(string variableName, string stringValue)

Parameters

  • variableNamestring
    the name of the variable
  • stringValuestring
    the new value

#TryGetValue<T>(string, T)

public override bool TryGetValue<T>(string variableName, [NotNullWhen(true)] out T result)

Parameters

  • variableNamestring
  • resultT

Returns Boolean

Generated from Yarn Spinner for Unity 3.3.