Line Presenter

The Line Presenter shows your dialogue one line at a time. It puts the speaker’s name in one text field and the line’s text in another, types the text out, and waits until it’s told to move on before handing control back to the Dialogue Runner.

The Line Presenter doesn’t listen for input itself. A separate component, the Line Advancer, listens for the player’s key presses and tells the Dialogue Runner to finish the line or move on.

If you added the Dialogue System prefab in Adding Presenters, you already have both.

The text fields it uses

A Line Presenter needs somewhere to put the text. In the Dialogue System prefab, that’s two TextMeshPro text fields inside a panel:

Dialogue System Dialogue RunnerIn Memory Variable Storage
Canvas CanvasCanvas ScalerGraphic Raycaster
Line Presenter Content Size FitterVertical Layout GroupCanvas GroupLine Presenter
Background ImageLayout Element
Character Name TextMeshPro - Text (UI)
Text TextMeshPro - Text (UI)
Button Container Line Presenter Button HandlerLayout Element
Continue Button ImageButton
The Line Presenter in the Dialogue System prefab, with its panel and text fields.

The Line Presenter doesn’t look for these by itself. You assign each one in the Inspector:

  • Line Text is the text field for the line’s text. In the prefab, that’s Text.
  • Name Field, under Character, is the text field for the speaker’s name. In the prefab, that’s Character Name.
  • Canvas Group is the Canvas Group the Line Presenter fades in and out. In the prefab, it’s on the Line Presenter’s own GameObject.
PLACEHOLDER — Screenshot needed
The Dialogue System prefab’s Line Presenter in the Scene view, with the panel showing the Character Name field across the top, the Text field under it, and the Continue Button in the bottom corner.
Line Text has to be set. If it’s empty, the Line Presenter skips every line and logs an error.

The Line Presenter hides its panel by setting the Canvas Group’s Alpha to 0 when dialogue starts and when it ends. To keep the panel hidden before the dialogue starts, set Alpha to 0 in the Inspector too. The Dialogue System prefab already does this.

Character names

Most lines in Yarn start with the speaker’s name, like Rosa: Are you here about the lamp?.

When the Line Presenter has a Name Field, it puts Rosa in the name field and Are you here about the lamp? in Line Text. If a line has no speaker, the name field is hidden. To hide something bigger than the text field itself, such as a name plate with a background, set Character Name Container to that GameObject, and the whole GameObject is hidden.

If there’s no Name Field at all, Shows Name In Line decides whether the name stays at the start of the text. It’s on by default, so the player sees Rosa: Are you here about the lamp?.

How text appears

By default, the text types out one letter at a time. Typewriter Style, under Typewriter, changes that:

StyleWhat it does
InstantShows the whole line at once.
By LetterTypes the line out one character at a time, at Letters per Second (60 by default).
By WordTypes the line out one word at a time, at Words per Second (10 by default).
CustomUses your own typewriter, set in Custom Typewriter. See Typewriter and Effects.
The four typewriter styles.

Setting Letters per Second or Words per Second to 0 shows the line at once. The Line Presenter sets up its typewriter when the scene starts, so changing these settings while the game is running has no effect.

Fade UI, under Fade, fades the panel in when a line starts and out when it ends. It’s on by default. Fade Up Duration and Fade Down Duration set how long each fade takes, in seconds. When the player moves on to the next line, the panel disappears at once without fading out. You only see the fade out when Auto Advance moves on by itself.

To change how text looks with markup, see Markup.

Continuing to the next line

Once a line has finished typing out, the Line Presenter waits until the Dialogue Runner tells it to move on. There are three ways to do that:

To move on without the player pressing anything, turn on Auto Advance, under Automatically Advance Dialogue. Once a line has finished typing out, the Line Presenter waits Delay Before Advancing seconds, 1 by default, and then moves on.

The continue button

The Line Presenter in the Dialogue System prefab has a continue button in the corner of its panel. While a line is on screen, clicking it moves on to the next line, even if the line is still typing out. While there’s no line, the button is turned off.

The button is run by the Line Presenter Button Handler component on Button Container. It has two settings:

SettingWhat it does
Continue ButtonThe Button the player clicks.
Dialogue RunnerThe Dialogue Runner to tell to move on.
The Line Presenter Button Handler’s settings.

The Line Presenter Button Handler is an event handler, so it only works when it’s in the Line Presenter’s Event Handlers list. In the prefab, it’s already there. To add a continue button to your own Line Presenter, add a Line Presenter Button Handler to a GameObject, set its two settings, and add it to Event Handlers.

Line Advancer

The Line Advancer listens for the player’s input, and tells the Dialogue Runner to finish the current line at once, move on to the next line, or end the whole conversation. It’s a Dialogue Presenter, so it goes in the Dialogue Runner’s Dialogue Presenters list alongside your Line Presenter, which is how it knows when a line or options arrive.

To add one, click Add Component on a GameObject and search for Line Advancer. Then set:

  • Runner to your Dialogue Runner.
  • Presenter to your Line Presenter. The Line Advancer watches the Line Presenter’s typewriter, so it knows when a line has finished typing out.
PLACEHOLDER — Screenshot needed
The Inspector for the Dialogue System prefab’s Line Advancer, showing Runner set to Dialogue System (Dialogue Runner), Presenter set to Line Presenter (Line Presenter), Separate Hurry Up And Advance Controls and Multi Advance Is Cancel turned off, and Input Mode set to Key Codes, with the Key Codes component underneath showing Hurry Up Line Key Code set to Space, Hurry Up Options Key Code set to Space and Cancel Dialogue Key Code set to None.

Hurrying up and moving on

By default, one input does two jobs:

  • If the line is still typing out, pressing Hurry Up Line finishes it immediately.
  • If the line is already complete, pressing Hurry Up Line again moves on to the next one.

Turn on Separate Hurry Up And Advance Controls to split these. Hurry Up Line then only finishes the line, and a second input, Next Line, moves on, even while the line is still typing out.

Turn on Multi Advance Is Cancel to move on after the player presses Hurry Up Line a set number of times on the same line, even if it hasn’t finished typing out. Advance Count sets how many presses, 2 by default.

Hurry Up Options makes options appear at once, without fading in. Cancel Dialogue stops the dialogue, the same as calling Stop() on the Dialogue Runner.

Presses in the same frame that a line or options arrive are ignored, so a key that picks an option doesn’t also hurry up the line that follows.

Input modes

Input Mode sets where the Line Advancer’s input comes from:

Input ModeWhat it does
Input ActionsUses actions from Unity’s Input System, such as a keyboard key or a gamepad button.
Key CodesUses keys on the keyboard.
ManualDoesn’t listen for input. Call the Line Advancer’s methods from your own code.
Legacy Input AxesUses buttons from Unity’s Input Manager.
Third-PartyUses another component on the same GameObject that implements ILineAdvancerInput, for input from a third-party input system.
The Line Advancer’s input modes.

When you choose Input Actions, Key Codes or Legacy Input Axes, the Line Advancer adds a matching component to its GameObject, where you choose the keys, buttons or actions. Changing the mode removes the old component and adds the new one.

Input Actions needs the Input System package installed and turned on in Project SettingsPlayerConfigurationActive Input Handling. Legacy Input Axes needs Input Manager (Old) turned on in the same setting. The Inspector shows a warning when the one you’ve chosen isn’t available. Key Codes works with either.

The Input Actions component has these settings:

SettingDefaultWhat it does
Hurry Up Line ActionnoneFinishes the current line, or moves on if it’s complete.
Next Line ActionnoneMoves on to the next line. Only shown when Separate Hurry Up And Advance Controls is on.
Hurry Up Options ActionnoneMakes options appear at once.
Cancel Dialogue ActionnoneStops the dialogue.
Enable ActionsOnTurns the actions on when dialogue starts. Turn it off if your game turns them on itself.
The Input Actions component’s settings.

The Key Codes component has these settings:

SettingDefaultWhat it does
Hurry Up Line Key CodeSpaceFinishes the current line, or moves on if it’s complete.
Next Line Key CodeEscapeMoves on to the next line.
Hurry Up Options Key CodeSpaceMakes options appear at once.
Cancel Dialogue Key CodeNoneStops the dialogue.
The Key Codes component’s settings.

Next Line Key Code is only shown when Separate Hurry Up And Advance Controls is on, but the Line Advancer responds to it either way. To turn it off, set it to None before you turn the setting off.

The Legacy Input Axes component has Hurry Up Line Axis, Next Line Axis, Hurry Up Options Axis and Cancel Dialogue Axis, which are the names of buttons from the Input Manager. They default to Jump, Cancel, Jump, and empty. The Line Advancer responds when the button is released.

The Line Advancer in the Dialogue System prefab

In the Dialogue System prefab, the Line Advancer is on its own GameObject:

Dialogue System Dialogue RunnerIn Memory Variable Storage
Canvas CanvasCanvas ScalerGraphic Raycaster
Line Presenter Content Size FitterVertical Layout GroupCanvas GroupLine Presenter
Options Presenter Vertical Layout GroupContent Size FitterCanvas GroupOptions Presenter
Line Advancer Line Advancer
The Line Advancer in the Dialogue System prefab.

Its Runner is the Dialogue System’s Dialogue Runner, its Presenter is the Line Presenter, and it’s in the Dialogue Runner’s Dialogue Presenters list. Input Mode is Key Codes, so when you add the prefab to a scene, the Line Advancer gets a Key Codes component with the defaults above:

  • Space finishes the current line, and moves on once it’s complete.
  • Escape moves on to the next line.
  • Space makes options appear at once.
  • Nothing ends the conversation.

Using the Line Advancer from code

With Input Mode set to Manual, the Line Advancer doesn’t listen for any input. Call its methods from your own code instead:

MethodWhat it does
RequestLineHurryUp()Finishes the current line immediately.
RequestNextLine()Moves on to the next line.
RequestOptionHurryUp()Makes options appear at once.
RequestDialogueCancellation()Stops the dialogue.
The Line Advancer’s methods.

RequestLineHurryUp() always finishes the line, and never moves on by itself, unless Multi Advance Is Cancel is on. To get the same behaviour as a key press, where pressing again once the line is complete moves on, call OnInputHurryUpLines() instead.

using UnityEngine;
using Yarn.Unity;

public class DialogueButtons : MonoBehaviour
{
    [SerializeField] LineAdvancer lineAdvancer;

    public void OnContinuePressed()
    {
        lineAdvancer.OnInputHurryUpLines();
    }

    public void OnSkipPressed()
    {
        lineAdvancer.RequestNextLine();
    }
}
Line 6 The Line Advancer. Drag it into this field in the Inspector.
Lines 8–11 Finishes the line if it’s still typing out, and moves on if it’s complete.
Lines 13–16 Moves on to the next line straight away.
Moving the dialogue on from your own button.

With Input Mode set to Third-Party, add a component of your own to the Line Advancer’s GameObject that implements ILineAdvancerInput. It calls the Line Advancer’s OnInputHurryUpLines(), OnInputNextContent(), OnInputHurryUpOptions() and OnInputCancelDialogue() when the player presses the matching input.

Line Advancer settings

SettingDefaultWhat it does
RunnernoneThe Dialogue Runner to tell to hurry up, move on, or stop.
PresenternoneThe Line Presenter whose typewriter the Line Advancer watches, to know when a line has finished typing out.
Separate Hurry Up And Advance ControlsOffUses one input to finish a line and another to move on.
Multi Advance Is CancelOffMoves on after Hurry Up Line is pressed Advance Count times on the same line.
Advance Count2How many presses move on. Only shown when Multi Advance Is Cancel is on.
Input ModeInput ActionsWhere the input comes from. The Dialogue System prefab uses Key Codes.
Every Line Advancer setting.

Settings

The Inspector for the Dialogue System prefab's Line Presenter, showing Canvas Group set to Line Presenter, Line Text set to Text, a Character group with Shows Name In Line turned on, Name Field set to Character Name and Character Name Container empty, a Fade group with Fade UI turned on, Fade Up Duration 0.25 and Fade Down Duration 0.1, an Automatically Advance Dialogue group with Auto Advance turned off, and a Typewriter group with Typewriter Style set to By Letter, Letters per Second 60, and one Event Handler, Button Container
The Line Presenter in the Dialogue System prefab. Its one event handler is the Line Presenter Button Handler that runs the continue button.
SettingDefaultWhat it does
Canvas GroupnoneThe Canvas Group that’s faded in and out, and hidden between lines.
Line TextnoneThe text field that shows the line’s text.
Shows Name In LineOnOnly used when there’s no Name Field: keeps the speaker’s name at the start of the text.
Name FieldnoneThe text field that shows the speaker’s name.
Character Name Containerthe name fieldHidden when a line has no speaker.
Fade UIOnFades the panel in and out around each line.
Fade Up Duration0.25Seconds to fade in. Only shown when Fade UI is on.
Fade Down Duration0.1Seconds to fade out. Only shown when Fade UI is on.
Auto AdvanceOffMoves on by itself once a line has finished typing.
Delay Before Advancing1Seconds to wait before moving on. Only shown when Auto Advance is on.
Typewriter StyleBy LetterHow the text appears.
Letters per Second60Typing speed in By Letter style. 0 shows the line at once.
Words per Second10Typing speed in By Word style. 0 shows the line at once.
Custom TypewriternoneYour own typewriter, used in Custom style.
Event HandlersemptyComponents that run game code partway through a line. See Markup.
Every Line Presenter setting.
Next step Options Presenter Showing options as buttons, and what happens to options the player can't choose.