Showing Dialogue
To show dialogue to the player, your scene needs a Dialogue Runner and at least one Dialogue Presenter.
The Dialogue Runner runs your Yarn Project. It works out what comes next, but doesn’t show anything. It hands each line, and each set of options, to your Dialogue Presenters, and each Presenter shows them in its own way, such as text in a box, buttons, or a voice clip.
A typical scene has a Dialogue Runner, two Presenters, one for lines and one for options, and a Line Advancer, which lets the player move on to the next line. The Dialogue System prefab has all of them, already connected:
To add it to your scene, open the GameObject menu and choose . If your scene already has an EventSystem, the one in the prefab is turned off.
The built-in Presenters
Yarn Spinner for Unity includes three Presenters. To add one to a GameObject, click Add Component in the Inspector and search for its name:
| Presenter | What it does |
|---|---|
| Line Presenter | Shows each line as text, with the speaker’s name, typing it out letter by letter or word by word. |
| Options Presenter | Shows each option as a button. |
| Voice Over Presenter | Plays a recorded clip for each line. |
You can use several at once. The Dialogue Runner gives each line to every Presenter at the same time, and moves on when they’ve all finished with it.
The Line Advancer works alongside them. It listens for the player’s input and tells the Presenters to finish the current line, or move on to the next one. See Line Presenter.
If none of these fit your game, write your own Presenter.
In this section
- Dialogue Runner: setting up the Dialogue Runner, starting and stopping dialogue, and its events.
- Line Presenter: showing lines, character names, typing speed, and continuing to the next line with the Line Advancer.
- Options Presenter: showing options as buttons, and what happens to options the player can’t choose.
- Typewriter and Effects: how text appears, and helpers for fades and shakes.
- Markup: formatting text, and running game code partway through a line.
- Voice-Over: playing a recorded clip for each line.
- Building Your Own Presenter: writing a Presenter for anything the built-in ones don’t cover.
- A Different Kind of Presenter: a second custom Presenter, which keeps the whole conversation on screen and takes options from the number keys.