# DialogueRunner

Class in [Yarn.Unity](/2.2/api/csharp/yarn.unity.md)

Inherits from `MonoBehaviour`

## Summary

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

```csharp
public class DialogueRunner : MonoBehaviour
```

## Classes

| Name                                                                                                                   | Description                                                  |
| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [StringUnityEvent](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.stringunityevent.md) | A type of `UnityEvent` that takes a single string parameter. |

## Fields

| Name                                                                                                                                 | Description                                                                                                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [dialogueViews](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.dialogueviews.md)                     | The View classes that will present the dialogue to the user.                                                                                                          |
| [lineProvider](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.lineprovider.md)                       |                                                                                                                                                                       |
| [onCommand](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.oncommand.md)                             | A [StringUnityEvent](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.stringunityevent.md) that is called when a `Command` is received. |
| [onDialogueComplete](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.ondialoguecomplete.md)           | A Unity event that is called once the dialogue has completed.                                                                                                         |
| [onNodeComplete](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.onnodecomplete.md)                   | A Unity event that is called when a node is complete.                                                                                                                 |
| [onNodeStart](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.onnodestart.md)                         | A Unity event that is called when a node starts running.                                                                                                              |
| [runSelectedOptionAsLine](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.runselectedoptionasline.md) | If true, when an option is selected, it's as though it were a line.                                                                                                   |
| [startAutomatically](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.startautomatically.md)           | Whether the DialogueRunner should automatically start running dialogue after the scene loads.                                                                         |
| [startNode](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.startnode.md)                             | The name of the node to start from.                                                                                                                                   |
| [verboseLogging](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.verboselogging.md)                   | If true, will print Debug.Log messages every time it enters a node, and other frequent events.                                                                        |
| [yarnProject](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.yarnproject.md)                         | The [YarnProject](/2.2/api/csharp/yarn.unity/yarn.unity.yarnproject.md) asset that should be loaded on scene start.                                                   |

## Methods

| Name                                                                                                                                                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AddCommandHandler(string,Delegate)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-1.md)                                        | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Action)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-9.md)                                   | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Func)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-2.md)                                     | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Action)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-10.md)                                  | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Func\<T1, Coroutine>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-3.md)                     | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Action\<T1, T2>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-11.md)                         | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Func\<T1, T2, Coroutine>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-4.md)                 | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Action\<T1, T2, T3>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-12.md)                     | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Func\<T1, T2, T3, Coroutine>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-5.md)             | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Action\<T1, T2, T3, T4>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-13.md)                 | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Func\<T1, T2, T3, T4, Coroutine>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-6.md)         | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Action\<T1, T2, T3, T4, T5>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-14.md)             | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Func\<T1, T2, T3, T4, T5, Coroutine>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-7.md)     | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Action\<T1, T2, T3, T4, T5, T6>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-15.md)         | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddCommandHandler(string,System.Func\<T1, T2, T3, T4, T5, T6, Coroutine>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addcommandhandler-8.md) | Adds a command handler. Dialogue will pause execution after the command is called.                                                                                                                                                                                                                                                                                                                         |
| [AddFunction(string,Delegate)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-1.md)                                                    | Add a new function that returns a value, so that it can be called from Yarn scripts.                                                                                                                                                                                                                                                                                                                       |
| [AddFunction(string,System.Func)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-2.md)                                                 | Add a new function that returns a value, so that it can be called from Yarn scripts.                                                                                                                                                                                                                                                                                                                       |
| [AddFunction(string,System.Func\<TResult, T1>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-3.md)                                   |                                                                                                                                                                                                                                                                                                                                                                                                            |
| [AddFunction(string,System.Func\<TResult, T1, T2>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-4.md)                               |                                                                                                                                                                                                                                                                                                                                                                                                            |
| [AddFunction(string,System.Func\<TResult, T1, T2, T3>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-5.md)                           |                                                                                                                                                                                                                                                                                                                                                                                                            |
| [AddFunction(string,System.Func\<TResult, T1, T2, T3, T4>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-6.md)                       |                                                                                                                                                                                                                                                                                                                                                                                                            |
| [AddFunction(string,System.Func\<TResult, T1, T2, T3, T4, T5>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-7.md)                   |                                                                                                                                                                                                                                                                                                                                                                                                            |
| [AddFunction(string,System.Func\<TResult, T1, T2, T3, T4, T5, T6>)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.addfunction-8.md)               |                                                                                                                                                                                                                                                                                                                                                                                                            |
| [Clear()](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.clear.md)                                                                                 | Unloads all nodes from the [Dialogue](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.dialogue.md) .                                                                                                                                                                                                                                                                        |
| [GetTagsForNode(String)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.gettagsfornode.md)                                                         | Returns the collection of tags that the node associated with the node named `nodeName`.                                                                                                                                                                                                                                                                                                                    |
| [LoadStateFromPlayerPrefs(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.loadstatefromplayerprefs.md)                                     | Loads all variables from the `PlayerPrefs` object into the Dialogue Runner's variable storage.                                                                                                                                                                                                                                                                                                             |
| [NodeExists(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.nodeexists.md)                                                                 | Returns `true` when a node named `nodeName` has been loaded.                                                                                                                                                                                                                                                                                                                                               |
| [OnViewRequestedInterrupt()](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.onviewrequestedinterrupt.md)                                           | Called by a [DialogueViewBase](/2.2/api/csharp/yarn.unity/yarn.unity.dialogueviewbase.md) derived class from [dialogueViews](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.dialogueviews.md) to inform the [DialogueRunner](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner.md) that the user intents to proceed to the next line.                                   |
| [RemoveCommandHandler(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.removecommandhandler.md)                                             | Removes a command handler.                                                                                                                                                                                                                                                                                                                                                                                 |
| [RemoveFunction(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.removefunction.md)                                                         | Remove a registered function.                                                                                                                                                                                                                                                                                                                                                                              |
| [ResetDialogue(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.resetdialogue.md)                                                           | Starts running the dialogue again.                                                                                                                                                                                                                                                                                                                                                                         |
| [SaveStateToPlayerPrefs(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.savestatetoplayerprefs.md)                                         | Saves all variables in the Dialogue Runner's variable storage into the `PlayerPrefs` object.                                                                                                                                                                                                                                                                                                               |
| [SetDialogueViews(DialogueViewBase\[\])](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.setdialogueviews.md)                                       | Sets the dialogue views and makes sure the callback `DialogueViewBase.MarkLineComplete` will respond correctly.                                                                                                                                                                                                                                                                                            |
| [SetInitialVariables(bool)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.setinitialvariables.md)                                                 | Loads any initial variables declared in the program and loads that variable with its default declaration value into the variable storage. Any variable that is already in the storage will be skipped, the assumption is that this means the value has been overridden at some point and shouldn't be otherwise touched. Can force an override of the existing values with the default if that is desired. |
| [SetProject(YarnProject)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.setproject.md)                                                            | Replaces this DialogueRunner's yarn project with the provided project.                                                                                                                                                                                                                                                                                                                                     |
| [SplitCommandText(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.splitcommandtext.md)                                                     | Splits input into a number of non-empty sub-strings, separated by whitespace, and grouping double-quoted strings into a single sub-string.                                                                                                                                                                                                                                                                 |
| [StartDialogue(string)](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.startdialogue.md)                                                           | Start the dialogue from a specific node.                                                                                                                                                                                                                                                                                                                                                                   |
| [Stop()](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.stop.md)                                                                                   | Stops the [Dialogue](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.dialogue.md) .                                                                                                                                                                                                                                                                                         |

## Properties

| Name                                                                                                                     | Description                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CurrentNodeName](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.currentnodename.md)     | Gets the name of the current node that is being run.                                                                                                       |
| [Dialogue](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.dialogue.md)                   | Gets the underlying [Dialogue](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.dialogue.md) object that runs the Yarn code. |
| [IsDialogueRunning](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.isdialoguerunning.md) | Gets a value that indicates if the dialogue is actively running.                                                                                           |
| [VariableStorage](/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.variablestorage.md)     | The variable storage object.                                                                                                                               |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yarnspinner.dev/2.2/api/csharp/yarn.unity/yarn.unity.dialoguerunner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
