All pages
Powered by GitBook
1 of 9

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

OnContinueClicked()

Method in LineView

Summary

Called when the Yarn.Unity.LineView.continueButton is clicked.

public void OnContinueClicked()

DialogueComplete()

Method in LineView

Summary

Called by the DialogueRunner to signal that the dialogue has ended, and no more lines will be delivered.

public override void DialogueComplete()

Remarks

This method is called after the last piece of content (that is, lines, options or commands) finished running.

This method is a good place to perform tasks like dismissing on-screen dialogue UI (for example, turning off a letterboxing effect, or hiding dialogue UI elements.)

If is called, this method is how your custom views are informed of this. This allows you to skip over the normal flow of dialogue, so please use this method to clean up your views.

The default implementation of this method does nothing.

PaletteMarkedUpText(Markup.MarkupParseResult,MarkupPalette)

Method in

Summary

Applies the palette to the line based on it's markup.

Stop()
Remarks

This is static so that other dialogue views can reuse this code. While this is simplistic it is useful enough that multiple pieces might well want it.

Parameters

Name
Description

line

The parsed marked up line with it's attributes.

palette

The palette mapping attributes to colours.

Returns

A TMP formatted string with the palette markup values injected within.

public static string PaletteMarkedUpText(Markup.MarkupParseResult line, MarkupPalette palette)
LineView

UserRequestedViewAdvancement()

Method in LineView

Summary

Called by DialogueAdvanceInput to signal that the user has requested that the dialogue advance.

public override void UserRequestedViewAdvancement()

Remarks

When this method is called, the Dialogue View should advance the dialogue. Advancing the dialogue can mean different things, depending on the nature of the dialogue view, and its current state.

In many situations, if the Dialogue View hasn't yet finished presenting its line (that is, the method has been called, but it hasn't yet called its completion handler), it's sufficient to call the method, which tells the Dialogue Runner to interrupt the current line.

'Advancing' the dialogue may not always mean finishing the line's presentation.

For example, in the Legend of Zelda series of games, lines of dialogue are displayed one character at a time in a text box, until the line has finished appearing. At this point, the text box displays a button to continue; when the user presses the primary input button (typically the A button), the line is dismissed. However, if this button is pressed while the line is still appearing, the rest of the line appears all at once, and the button appears. Finally, if a secondary input button (typically the B button) is pressed at any point, the line is interrupted, and the dialogue proceeds to the next line immediately.

is designed to give your Dialogue View an opportunity to decide whether it wants to interrupt the entire line for all views, or simply speed up the delivery of this view.

The default implementation of this method does nothing.

LineView

Class in Yarn.Unity

Inherits from DialogueViewBase

Summary

A Dialogue View that presents lines of dialogue, using Unity UI elements.

public class LineView : DialogueViewBase

Methods

Name
Description

GetPauseDurationsInsideLine(Markup.MarkupParseResult)

Method in LineView

Summary

Creates a stack of typewriter pauses to use to temporarily halt the typewriter effect.

public static Stack<(int position, float duration)> GetPauseDurationsInsideLine(Markup.MarkupParseResult line)

Remarks

This is intended to be used in conjunction with the effect. The stack of tuples created are how the typewriter effect knows when, and for how long, to halt the effect.

The pause duration property is in milliseconds but all the effects code assumes seconds So here we will be dividing it by 1000 to make sure they interconnect correctly.

Parameters

Name
Description

Returns

A stack of positions and duration pause tuples from within the line

DismissLine(Action)

Method in

Summary

Called by the to signal that the view should dismiss its current line from display, and clean up.

RunLine(LocalizedLine,Action)
requestInterrupt
UserRequestedViewAdvancement()

Yarn.Markup.MarkupParseResult line

The line from which we covet the pauses

PausableTypewriter(TextMeshProUGUI,float,Action,Action,Action,Stack<(int position, float duration)>,CoroutineInterruptToken)
Yarn.Markup.MarkupParseResult
Yarn.Unity.MarkupPalette
Remarks

This method is called when all Dialogue Views attached to a Dialogue Runner report that they have finished presenting this line. When this occurs, the Dialogue Runner calls DismissLine(Action) on all Dialogue Views to tell them to clear their current line from display.

Depending on how the Dialogue View presents lines, "dismissing" a line may mean different things. For example, a Dialogue View that presents on-screen text might fade the text away, or a Dialogue View that presents voice-over dialogue may not need to do anything at all (because audio finished playing when the line finished presenting.)

Dismissing the line can take time, but should ideally be as fast as possible, because the user will be waiting for the next piece of content to appear.

When the line has finished dismissing, this method calls onDismissalComplete to indicate that the dismissal is complete. When all Dialogue Views on a Dialogue Runner have finished dismissing, the Dialogue Runner moves on to the next piece of content.

The default implementation of this method immediately calls the onDismissalComplete method (that is, it reports that it has finished dismissing the line the moment that it receives it), and otherwise does nothing.

Parameters

Name
Description

System.Action onDismissalComplete

The method that should be called when the view has finished dismissing the line.

LineView
DialogueRunner
public override void DismissLine(Action onDismissalComplete)

Applies the palette to the line based on it's markup.

Called by the to signal that a line should be displayed to the user.

Called by to signal that the user has requested that the dialogue advance.

DialogueComplete()

Called by the DialogueRunner to signal that the dialogue has ended, and no more lines will be delivered.

DismissLine(Action)

Called by the DialogueRunner to signal that the view should dismiss its current line from display, and clean up.

GetPauseDurationsInsideLine(Markup.MarkupParseResult)

Creates a stack of typewriter pauses to use to temporarily halt the typewriter effect.

InterruptLine(LocalizedLine,Action)

Called by the DialogueRunner to signal that a line has been interrupted, and that the Dialogue View should finish presenting its line as quickly as possible.

OnContinueClicked()

Called when the Yarn.Unity.LineView.continueButton is clicked.

RunLine(LocalizedLine,Action)

Method in

Summary

Called by the to signal that a line should be displayed to the user.

PaletteMarkedUpText(Markup.MarkupParseResult,MarkupPalette)
RunLine(LocalizedLine,Action)
DialogueRunner
UserRequestedViewAdvancement()
DialogueAdvanceInput
Remarks

When this method is called, the Dialogue View should present the line to the user. The content to present is contained within the dialogueLine parameter, which contains information about the line in the user's current locale.

The value of the dialogueLine parameter is produced by the Dialogue Runner's LineProviderBehaviour.

It's up to the Dialogue View to decide what "presenting" the line may mean; for example, showing on-screen text, or playing voice-over audio.

When the line has finished being presented, this method calls the onDialogueLineFinished method, which signals to the Dialogue Runner that this Dialogue View has finished presenting the line. When all Dialogue Views have finished presenting the line, the Dialogue Runner calls DismissLine(Action) to signal that the views should get rid of the line.

If you want to create a Dialogue View that waits for user input before continuing, either wait for that input before calling onDialogueLineFinished, or don't call it at all and instead call requestInterrupt to tell the Dialogue Runner to interrupt the line.

The onDialogueLineFinished method should only be called when RunLine(LocalizedLine,Action) finishes its presentation normally. If InterruptLine(LocalizedLine,Action) has been called, you must call the completion handler that it receives, and not the completion handler that RunLine(LocalizedLine,Action) has received.

The default implementation of this method immediately calls the onDialogueLineFinished method (that is, it reports that it has finished presenting the line the moment that it receives it), and otherwise does nothing.

Parameters

Name
Description

dialogueLine

The content of the line that should be presented to the user.

System.Action onDialogueLineFinished

The method that should be called after the line has finished being presented.

See Also

  • DialogueViewBase.InterruptLine(LocalizedLine,Action): Called by the DialogueRunner to signal that a line has been interrupted, and that the Dialogue View should finish presenting its line as quickly as possible.

  • DialogueViewBase.DismissLine(Action): Called by the DialogueRunner to signal that the view should dismiss its current line from display, and clean up.

  • DialogueViewBase.RunOptions(DialogueOption[],Action<int>): Called by the DialogueRunner to signal that a set of options should be displayed to the user.

LineView
DialogueRunner

InterruptLine(LocalizedLine,Action)

Method in LineView

Summary

Called by the DialogueRunner to signal that a line has been interrupted, and that the Dialogue View should finish presenting its line as quickly as possible.

Remarks

This method is called when Dialogue Runner wants to interrupt the presentation of the current line, in order to proceed to the next piece of content.

When this method is called, the Dialogue View must finish presenting their line as quickly as it can. Depending on how this Dialogue View presents lines, this can mean different things: for example, a view that plays voice-over audio might stop playback immediately, or fade out playback over a short period of time; a view that displays text a letter at a time might display all of the text at once.

The process of finishing the presentation can take time to complete, but should happen as quickly as possible, because this method is generally called when the user wants to skip the current line.

When the line has finished presenting, the onDialogueLineFinished method must be called, which indicates to the Dialogue Runner that this line is ready to be dismissed.

When is called, you must not call the completion handler that has previously received - this completion handler is no longer valid. Call this method's onDialogueLineFinished instead.

The default implementation of this method immediately calls the onDialogueLineFinished method (that is, it reports that it has finished presenting the line the moment that it receives it), and otherwise does nothing.

Parameters

Name
Description

See Also

  • : Called by the to signal that a line should be displayed to the user.

  • : Called by the to signal that the view should dismiss its current line from display, and clean up.

public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
public override void InterruptLine(LocalizedLine dialogueLine, Action onInterruptLineFinished)

Yarn.Unity.LocalizedLine dialogueLine

The current line that is being presented.

onDialogueLineFinished

The method that should be called after the line has finished being presented.

System.Action onInterruptLineFinished

InterruptLine(LocalizedLine,Action)
RunLine(LocalizedLine,Action)
DialogueViewBase.RunLine(LocalizedLine,Action)
DialogueRunner
DialogueViewBase.DismissLine(Action)
DialogueRunner
Yarn.Unity.LocalizedLine