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:

SampleScene
Main Camera CameraAudio Listener
Dialogue System Dialogue RunnerIn Memory Variable Storage
Canvas CanvasCanvas ScalerGraphic Raycaster
Line Presenter Line PresenterCanvas Group
Background Image
Character Name TextMeshPro - Text (UI)
Text TextMeshPro - Text (UI)
Button Container Line Presenter Button Handler
Continue Button ImageButton
Options Presenter Options PresenterCanvas Group
Background Image
Last Line TextMeshPro - Text (UI)
Markup Processors Palette Marker ProcessorStyle Marker Processor
Line Advancer Line Advancer
EventSystem Event System
The Dialogue System prefab in a scene. The labels after each GameObject’s name are its components.

To add it to your scene, open the GameObject menu and choose Yarn SpinnerDialogue System. 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:

PresenterWhat it does
Line PresenterShows each line as text, with the speaker’s name, typing it out letter by letter or word by word.
Options PresenterShows each option as a button.
Voice Over PresenterPlays a recorded clip for each line.
The Presenters that come with Yarn Spinner for Unity.

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.
Get started Dialogue Runner Setting up the Dialogue Runner, starting and stopping dialogue, and its events.