> For the complete documentation index, see [llms.txt](https://giantgrey.gitbook.io/databrain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://giantgrey.gitbook.io/databrain/add-ons/dialogue/dialogue-runtime-setup.md).

# Dialogue runtime setup

## Scene Setup

Follow these steps for the runtime scene setup.

1. Create an empty GameObject in your scene and call it DialogueController.
2. Add the DialogueController component to it.

<div align="left"><figure><img src="https://2348672745-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIoqF5QAgQsqxrjmTIKpE%2Fuploads%2F19FZqEXH1TYhlNVjVB3Q%2Fdialogue_dialogueController.png?alt=media&amp;token=ff8dfcc1-00cb-49d4-9232-7df08ca80b70" alt=""><figcaption></figcaption></figure></div>

3. On the DialogueController, assign the DataLibrary in which your dialogue has been created.
4. Select the dialogue graph from the dropdown.
5. Now you'll need to assign a dialogue theme. You can find three ready to use themes in the folder:\
   **Dialogue / Themes**\
   Drag a theme prefab inside of a Canvas GameObject in the scene, then assign it to the DialogueController component.
6. Set a language - if you have defined some in your dialogue graph.
7. If you have any audio clips in your dialogue you'll have to assign the audio sources in the audiosources list. You can read more about the audio setup here ->&#x20;

<div align="left"><figure><img src="https://2348672745-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIoqF5QAgQsqxrjmTIKpE%2Fuploads%2Fq1UX4bnkP4hLg8Aome6H%2Fdialogue_sceneHierarchy.png?alt=media&amp;token=c8dc145c-d8d7-4d51-bc74-03e2a9864252" alt=""><figcaption><p>Your scene hierarchy should look similar to this</p></figcaption></figure></div>

## Start a Dialogue

All relevant API methods are inside of the DialogueController component.\
If you want to start a dialogue simply call:

```csharp
dialogueController.StartDialogue();
```

Here's a simple script which will start a dialogue on press of an IMGUI button:

```csharp
using UnityEngine;
using Databrain.Dialogue;

public class StartDialogue : MonoBehaviour
{
    // Reference to the dialogue controller
    public DialogueController dialogueController;
    
    public void OnGUI()
    {
        if (GUILayout.Button("Start Dialogue"))
        {
            dialogueController.StartDialogue();
        }
    }
}
```

{% hint style="info" %}
By calling the StartDialogue method, the assigned dialogue theme which has the **IDialogueUIControl** interface implemented will receive a call on the OnDialogueStart method.
{% endhint %}
