DialogueRunner Class

The DialogueRunner component acts as the interface between your game and Yarn Spinner.

[AddComponentMenu("Scripts/Yarn Spinner/Dialogue Runner")]
public class DialogueRunner : MonoBehaviour, ILineLocalisationProvider

Methods

Name Description
Add(YarnProgram) Adds a program, and parses and adds the contents of the program’s string table to the DialogueRunner’s combined string table.
AddCommandHandler(String, DialogueRunner.BlockingCommandHandler) Adds a command handler. Dialogue will pause execution after the command is called.
AddCommandHandler(String, DialogueRunner.CommandHandler) Adds a command handler. Dialogue will continue running after the command is called.
AddFunction(String, Int32, Function) Add a new function, so that it can be called from Yarn scripts.
AddFunction(String, Int32, ReturningFunction) Add a new function that returns a value, so that it can be called from Yarn scripts.
AddStringTable(IDictionary<String, StringInfo>) Adds entries to the DialogueRunner’s combined string table.
AddStringTable(YarnProgram) Parses and adds the contents of a string table from a yarn asset to the DialogueRunner’s combined string table.
Clear() Unloads all nodes from the Yarn.Unity.DialogueRunner.dialogue.
NodeExists(String) Returns true when a node named nodeName has been loaded.
RemoveCommandHandler(String) Removes a command handler.
RemoveFunction(String) Remove a registered function.
ResetDialogue() Resets the variableStorage, and starts running the dialogue again from the node named startNode.
StartDialogue() Starts running dialogue. The node specified by startNode will start running.
StartDialogue(String) Start the dialogue from a specific node.
Stop() Stops the Yarn.Unity.DialogueRunner.dialogue.
ILineLocalisationProvider.GetLocalisedTextForLine(Line) Returns the user-facing text for a given Line.

Properties

Name Description
CurrentNodeName Gets the name of the current node that is being run.
Dialogue Gets the underlying Dialogue object that runs the Yarn code.
IsDialogueRunning Gets a value that indicates if the dialogue is actively running.

Fields

Name Description
dialogueUI The object that will handle the actual display and user input.
onDialogueComplete A Unity event that is called once the dialogue has completed.
onNodeComplete A Unity event that is called when a node is complete.
startAutomatically Whether the DialogueRunner should automatically start running dialogue after the scene loads.
startNode The name of the node to start from.
textLanguage The language code used to select a string table.
variableStorage The variable storage object.
yarnScripts The YarnProgram assets that should be loaded on scene start.

Source

Defined in Unity/Assets/YarnSpinner/Scripts/DialogueRunner.cs, line 44.