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).

VariableStorageBehaviour

A MonoBehaviour that a DialogueRunner uses to store and retrieve variables.
public abstract class VariableStorageBehaviour : MonoBehaviour, Yarn.IVariableStorage

Inherits from MonoBehaviour

Implements Yarn.IVariableStorage, Yarn.IVariableAccess

This abstract class inherits from 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; }

Type ISmartVariableEvaluator

#Methods

#AddChangeListener(System.Action<string, object>)

Registers a delegate that will be called when any variable is modified.
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>)

Registers a delegate that will be called when the variable variableName is modified.
public IDisposable AddChangeListener<T>(string variableName, Action<T> onChange)

Type Parameters

  • T
    The type of the variable.

Parameters

  • variableNamestring
    The name of the variable to watch for changes to. This variable must be of type T, 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.InvalidOperationException
    Called when Program is not set.
  • System.ArgumentException
    Called when variableName is not the name of a valid variable, or if T does not match the type of the variable.

#Clear()

public abstract void Clear();

#Contains(string)

Returns a boolean value representing if a particular variable is inside the variable storage.
public abstract bool Contains(string variableName);

Parameters

  • variableNamestring
    The 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()

Provides a unified interface for exporting all variables. Intended to be a point for custom saving, editors, etc.
public abstract (FloatDictionary FloatVariables, StringDictionary StringVariables, BoolDictionary BoolVariables) GetAllVariables();

Returns ValueTuple

#GetVariableKind(string)

public VariableKind GetVariableKind(string name)

Parameters

  • namestring

Returns VariableKind

#SetAllVariables(FloatDictionary, StringDictionary, BoolDictionary, bool)

Provides a unified interface for loading many variables all at once. Will override anything already in the variable storage.
public abstract void SetAllVariables(FloatDictionary floats, StringDictionary strings, BoolDictionary 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)

public abstract void SetValue(string variableName, bool boolValue);

Parameters

  • variableNamestring
  • boolValuebool

#SetValue(string, float)

public abstract void SetValue(string variableName, float floatValue);

Parameters

  • variableNamestring
  • floatValuefloat

#SetValue(string, string)

public abstract void SetValue(string variableName, string stringValue);

Parameters

  • variableNamestring
  • stringValuestring

#TryGetValue<T>(string, T?)

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

Parameters

  • variableNamestring
  • resultT

Returns Boolean

Generated from Yarn Spinner for Unity 3.3.