Dialogue Runner

The Dialogue Runner is responsible for loading Yarn Programs, running their contents, and communicating with the Dialogue UI. The Dialogue Runner is also responsible for managing the loaded string tables, and selecting which language to use.

The Inspector

Loading Yarn Programs with Code

When the Dialogue Runner starts, it will load all of the Yarn Programs specified in the Yarn Scripts field. If you want to provide a Yarn Program via code, you can use the the Add method to load them.

The following code demonstrates how to use Add to load a Yarn Program.

public class NPC : MonoBehaviour {

    // The Yarn Program we want to load
    public YarnProgram scriptToLoad;

    // The dialogue runner we want to load the program into
    public DialogueRunner dialogueRunner;

    void Start () {
        // Load the program, along with all of its nodes. 
        // The string table will be selected based on the 
        // Dialogue Runner's text language variable.