Method in AsyncDialogueViewBase
Called by the DialogueRunner to signal that the dialogue has ended, and no more lines will be delivered.
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.
A task that represents any work done by this dialogue view in order to clean up after running dialogue.
Class in
Inherits from UnityEngine.MonoBehaviour
A UnityEngine.MonoBehaviour
that can present lines and options to the user, when it receives them from a .
When the Dialogue Runner encounters content that the user should see - that is, lines or options - it sends that content to all of the dialogue views stored in Yarn.Unity.DialogueRunner.dialogueViews
. The Dialogue Runner then waits until all Dialogue Views have reported that they have finished presenting the content.
To use this class, subclass it, and implement its required methods. Once you have written your subclass, attach it as a component to a UnityEngine.GameObject
, and add this game object to the list of Dialogue Views in your scene's .
Dialogue Views do not need to handle every kind of content that the Dialogue Runner might produce. For example, you might have one Dialogue View that handles Lines, and another that handles Options. The built-in class is an example of this, in that it only handles Lines and does nothing when it receives Options.
You may also have multiple Dialogue Views that handle the same kind of content. For example, you may have a Dialogue View that receives Lines and uses them to play voice-over audio, and a second Dialogue View that also receives Lines and uses them to display on-screen subtitles.
Yarn.Unity.DialogueRunner.dialogueViews:
Method in
Called by the to signal that a set of options should be displayed to the user.
This method is called when the Dialogue Runner wants to show a collection of options that the user should choose from. Each option is represented by a object, which contains information about the option.
When this method is called, the Dialogue View should display appropriate user interface elements that let the user choose among the options.
This method should await until an option is selected, and then return the selected option. If this view doesn't handle options, or is otherwise unable to select an option, it should return YarnAsync.NoOptionSelected
. The dialogue runner will wait for all dialogue views to return, so if a dialogue view doesn't or can't handle options, it's good practice to return as soon as possible.
If the cancellationToken
becomes cancelled, this means that the dialogue runner no longer needs this dialogue view to make a selection, and this method should return as soon as possible; its return value will not be used.
The default implementation of this method returns YarnAsync.NoOptionSelected
.
A task that indicates which option was selected, or that this dialogue view did not select an option.
YarnAsync.NoOptionSelected
Method in
Called by the to signal that dialogue has started.
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.
A task that represents any work done by this dialogue view in order to get ready for dialogue to run.
Method in
Called by the to signal that a line should be displayed to the user.
When this method is called, the Dialogue View should present the line to the user. The content to present is contained within the line
parameter, which contains information about the line in the user's current locale.
It's up to the Dialogue View to decide what "presenting" the line may mean; for example, showing on-screen text, playing voice-over audio, or updating on-screen portraits to show a picture of the speaking character.
The will wait until the tasks from all of its dialogue views have completed before continuing to the next piece of content. If your dialogue view does not need to handle the line, it should return immediately.
The value of the line
parameter is produced by the Dialogue Runner's .
The default implementation of this method takes no action and returns immediately.
A task that completes when the dialogue view has finished showing the line to the user.
: A UnityEngine.MonoBehaviour
that produces s, for use in Dialogue Views.
: Called by the to signal that a line should be displayed to the user.
: Called by the to signal that a set of options should be displayed to the user.
The set of options that should be displayed to the user.
System.Threading.CancellationToken
cancellationToken
A System.Threading.CancellationToken
that becomes cancelled when the dialogue runner no longer needs this dialogue view to return an option.
The line to present.
Called by the to signal that the dialogue has ended, and no more lines will be delivered.
Called by the to signal that dialogue has started.
Called by the to signal that a line should be displayed to the user.
Called by the to signal that a set of options should be displayed to the user.
dialogueOptions
line
token
A that represents whether the dialogue view should hurry it its presentation of the line, or stop showing the current line.