All pages
Powered by GitBook
1 of 17

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

LinePresenter

Class in Yarn.Unity

Inherits from DialoguePresenterBase

Summary

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

Fields

Name
Description

autoAdvance

Controls whether this Line View will automatically to the Dialogue Runner that the line is complete as soon as the line has finished appearing.

autoAdvanceDelay

The amount of time after the line finishes appearing before automatically ending the line, in seconds.

canvasGroup

The canvas group that contains the UI elements used by this Line View.

characterNameContainer

The game object that holds the characterNameText text field.

characterNameText

The TMPro.TMP_Text object that displays the character names found in dialogue lines.

customTypewriter

fadeDownDuration

The time that the fade effect will take to fade lines out.

fadeUpDuration

The time that the fade effect will take to fade lines in.

lettersPerSecond

The number of characters per second that should appear during a typewriter effect.

lineText

The TMPro.TMP_Text object that displays the text of dialogue lines.

showCharacterNameInLine

Controls whether the lineText object will show the character name present in the line or not.

useFadeEffect

Controls whether the line view should fade in when lines appear, and fade out when lines disappear.

wordsPerSecond

Methods

Name
Description

OnDialogueCompleteAsync()

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

OnDialogueStartedAsync()

Called by the DialogueRunner to signal that dialogue has started.

RunLineAsync(LocalizedLine,LineCancellationToken)

Presents a line using the configured text view.

autoAdvance

Field in LinePresenter

Summary

Controls whether this Line View will automatically tell the Dialogue Runner that the line is complete as soon as the line has finished appearing.

Remarks

If this value is true, the Line View will

The DialogueRunner will not proceed to the next piece of content (e.g. the next line, or the next options) until all Dialogue Presenters have reported that they have finished presenting their lines. If a LinePresenter doesn't report that it's finished until it receives input, the DialogueRunner will end up pausing.

This is useful for games in which you want the player to be able to read lines of dialogue at their own pace, and give them control over when to advance to the next line.

autoAdvanceDelay

Field in LinePresenter

Summary

The amount of time after the line finishes appearing before automatically ending the line, in seconds.

public float autoAdvanceDelay = 1f;

Remarks

This value is only used when autoAdvance is true .

canvasGroup

Field in LinePresenter

Summary

The canvas group that contains the UI elements used by this Line View.

Remarks

If useFadeEffect is true, then the alpha value of this UnityEngine.CanvasGroup will be animated during line presentation and dismissal.

See Also

  • LinePresenter.useFadeEffect: Controls whether the line view should fade in when lines appear, and fade out when lines disappear.

characterNameContainer

Field in LinePresenter

Summary

The game object that holds the characterNameText text field.

public GameObject? characterNameContainer = null;

Remarks

This is needed in situations where the character name is contained within an entirely different game object. Most of the time this will just be the same game object as characterNameText .

characterNameText

Field in LinePresenter

Summary

The TMPro.TMP_Text object that displays the character names found in dialogue lines.

public TMP_Text? characterNameText = null;

Remarks

If the LinePresenter receives a line that does not contain a character name, this object will be left blank.

customTypewriter

Field in LinePresenter

Summary

public UnityEngine.Object? customTypewriter;

fadeDownDuration

Field in LinePresenter

Summary

The time that the fade effect will take to fade lines out.

Remarks

This value is only used when useFadeEffect is true .

See Also

  • LinePresenter.useFadeEffect: Controls whether the line view should fade in when lines appear, and fade out when lines disappear.

fadeUpDuration

Field in LinePresenter

Summary

The time that the fade effect will take to fade lines in.

Remarks

This value is only used when useFadeEffect is true .

See Also

  • LinePresenter.useFadeEffect: Controls whether the line view should fade in when lines appear, and fade out when lines disappear.

lettersPerSecond

Field in LinePresenter

Summary

The number of characters per second that should appear during a typewriter effect.

public int lettersPerSecond = 60;

lineText

Field in LinePresenter

Summary

The TMPro.TMP_Text object that displays the text of dialogue lines.

public TMP_Text? lineText;

showCharacterNameInLine

Field in LinePresenter

Summary

Controls whether the lineText object will show the character name present in the line or not.

Remarks

This value is only used if characterNameText is null.

If this value is true, any character names present in a line will be shown in the lineText object.

If this value is false, character names will not be shown in the lineText object.

useFadeEffect

Field in LinePresenter

Summary

Controls whether the line view should fade in when lines appear, and fade out when lines disappear.

Remarks

If this value is true, the canvasGroup object's alpha property will animate from 0 to 1 over the course of fadeUpDuration seconds when lines appear, and animate from 1 to zero over the course of fadeDownDuration seconds when lines disappear.

If this value is false, the canvasGroup object will appear instantaneously.

See Also

  • LinePresenter.canvasGroup: The canvas group that contains the UI elements used by this Line View.

  • LinePresenter.fadeUpDuration: The time that the fade effect will take to fade lines in.

  • LinePresenter.fadeDownDuration: The time that the fade effect will take to fade lines out.

wordsPerSecond

Field in LinePresenter

Summary

public int wordsPerSecond = 10;

OnDialogueCompleteAsync()

Method in LinePresenter

Summary

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

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.)

The default implementation of this method does nothing.

Returns

A task that represents any work done by this dialogue presenter in order to clean up after running dialogue.

OnDialogueStartedAsync()

Method in LinePresenter

Summary

Called by the DialogueRunner to signal that dialogue has started.

Remarks

This method is called before any content (that is, lines, options or commands) are delivered.

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

The default implementation of this method does nothing.

Returns

A task that represents any work done by this dialogue presenter in order to get ready for dialogue to run.

RunLineAsync(LocalizedLine,LineCancellationToken)

Method in LinePresenter

Summary

Presents a line using the configured text view.

Parameters

Name
Description

Yarn.Unity.LocalizedLine line

The line to present.

Yarn.Unity.LineCancellationToken token

A LineCancellationToken that represents whether the dialogue presenter should hurry it its presentation of the line, or stop showing the current line.

Returns

A task that completes when the dialogue presenter has finished showing the line to the user.

public sealed class LinePresenter : DialoguePresenterBase
public bool autoAdvance = false;
public CanvasGroup? canvasGroup;
public float fadeDownDuration = 0.1f;
public float fadeUpDuration = 0.25f;
public bool showCharacterNameInLine = true;
public bool useFadeEffect = true;
public override YarnTask OnDialogueCompleteAsync()
public override YarnTask OnDialogueStartedAsync()
public override async YarnTask RunLineAsync(LocalizedLine line, LineCancellationToken token)