> For the complete documentation index, see [llms.txt](https://espergames.gitbook.io/feel-speak/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://espergames.gitbook.io/feel-speak/scripting/dialogue-box.md).

# Dialogue Box

Scripting with the DialogueBox class.

The `DialogueBox` class runs a `DialogueGraph`.

## Notes

* All properties visible in the inspector are available through code.

## Getting a Dialogue Box

Aside from the usual way of referencing components in Unity, you have multiple ways to get a dialogue box.

Feel Speak keeps track of all dialogue boxes in the scene. To access the list of all dialogue boxes, use `DialogueBox.Instances`.

To get a specific dialogue box by its `GameObject` name, use `DialogueBox.Find`.

```csharp
DialogueBox myDialogueBox = DialogueBox.Find("My Dialogue Box");
```

If you only have one in the scene at all times, just use `DialogueBox.First`.

## Starting Dialogue

To start dialogue, use the `StartDialogue` method and pass a `DialogueGraph`.

```csharp
myDialogueBox.StartDialogue(myDialogueGraph);
```

You can prepare dialogue before starting it with `PrepareDialogue`.

```csharp
myDialogueBox.PrepareDialogue(myDialogueGraph);
```

This can also be done asynchronously with `PrepareDialogueAsync`.

```csharp
await myDialogueBox.PrepareDialogueAsync(myDialogueGraph);
```

## Ending Dialogue

Dialogue ends automatically when there are no more nodes in the dialogue graph to continue the conversation. However, you can forcefully end it with `EndDialogue`.

```csharp
myDialogueGraph.EndDialogue();
```

## Fast Forward

You can fast forward (or skip) through dialogue with the `FastForward` method.

```csharp
myDialogueGraph.FastForward();
```

## State Checks

You can check the current state of the dialogue box with the properties below.

| Name                | Type       | Description                                                                                                                                                                       |
| ------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `IsDelayOn`         | `bool`     | If dialogue continuation is currently delayed due to a delay node.                                                                                                                |
| `IsTextPauseActive` | `bool`     | If the dialogue text is currently paused due to a sentence ender or a tag. Pauses are usually very short. This value will be updated immediately as the text pause state changes. |
| `IsPrimaryActive`   | `bool`     | If the primary dialogue speaker is currently active.                                                                                                                              |
| `IsSecondaryActive` | `bool`     | If the secondary dialogue speaker is currently active.                                                                                                                            |
| `IsTypingOut`       | `bool`     | If the text is currently being typed out.                                                                                                                                         |
| `IsOpen`            | `bool`     | If the dialogue box is currently open.                                                                                                                                            |
| `IsDialogueRunning` | `bool`     | If the dialogue box is actively displaying dialogue.                                                                                                                              |
| `ActiveDialogue`    | `Dialogue` | The dialogue that is currently running.                                                                                                                                           |

## Current Speaker

You can check if a `Speaker` or `Character` is currently speaking with the `IsSpeaking` method.

```csharp
bool isSpeaking = myDialogueBox.IsSpeaking(myCharacter);
```

Use `GetPresentSpeaker` to get a speaker currently engaged in dialogue by the name of the character. Note that the character must be either the current primary or secondary speaker.

```csharp
DialogueSpeaker myDialogueSpeaker = myDialogueBox.GetPresentSpeaker("My Character")
```

A `DialogueSpeaker` simply displays a `Speaker` in the UI. It stores a reference to the `Speaker`, `Character`, `EmotionBubble`, and the current `Emotion` that the character is expressing.

## Trigger Emotion Bubble

You can trigger an emotion bubble of a specific character that is currently engaging in dialogue with the `TriggerEmotionBubble` method.

```csharp
myDialogueBox.TriggerEmotionBubble("My Character");
```
