All pages
Powered by GitBook
1 of 10

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Start()

Method in

public void Start();

Summary

CoroutineInterruptToken

Interrupt()

Method in

public void Interrupt()

Summary

CoroutineInterruptToken

Complete()

Method in

public void Complete();

Summary

CoroutineInterruptToken

CoroutineInterruptToken

Class in Effects

Inherits from System.Object

Summary

An object that can be used to signal to a coroutine that it should terminate early.

public class CoroutineInterruptToken

Remarks

While coroutines can be stopped by calling UnityEngine.MonoBehaviour.StopCoroutine(System.Collections.IEnumerator) or UnityEngine.MonoBehaviour.StopAllCoroutines, this has the side effect of also stopping any coroutine that was waiting for the now-stopped coroutine to finish.

Instances of this class may be passed as a parameter to a coroutine that they can periodically poll to see if they should terminate earlier than planned.

To use this class, create an instance of it, and pass it as a parameter to your coroutine. In the coroutine, call to mark that the coroutine is running. During the coroutine's execution, periodically check the property to determine if the coroutine should exit. If it is true, the coroutine should exit (via the yield break statement.) At the normal exit of your coroutine, call the method to mark that the coroutine is no longer running. To make a coroutine stop, call the method.

You can also use the property to determine if the token is in a state in which it can stop (that is, a coroutine that's using it is currently running.)

Name
Description
Name
Description

Methods

Properties

Start()
WasInterrupted
Complete()
Interrupt()
CanInterrupt

Complete()
Interrupt()
CanInterrupt
WasInterrupted
Start()

Effects

Class in Yarn.Unity

Inherits from System.Object

Summary

Contains coroutine methods that apply visual effects. This class is used by LineView to handle animating the presentation of lines.

public static class Effects

Classes

Name
Description
Name
Description

An object that can be used to signal to a coroutine that it should terminate early.

A coroutine that fades a UnityEngine.CanvasGroup object's opacity from from to to over the course of fadeTime seconds, and then invokes onComplete .

A coroutine that gradually reveals the text in a TMPro.TextMeshProUGUI object over time.

Methods

Typewriter(TextMeshProUGUI,float,Action,CoroutineInterruptToken)

A coroutine that gradually reveals the text in a TMPro.TextMeshProUGUI object over time.

CoroutineInterruptToken
FadeAlpha(CanvasGroup,float,float,float,CoroutineInterruptToken)
PausableTypewriter(TextMeshProUGUI,float,Action,Action,Action,Stack<(int position, float duration)>,CoroutineInterruptToken)

PausableTypewriter(TextMeshProUGUI,float,Action,Action,Action,Stack<(int position, float duration)>,CoroutineInterruptToken)

Method in Effects

Summary

A coroutine that gradually reveals the text in a TMPro.TextMeshProUGUI object over time.

public static IEnumerator PausableTypewriter(TextMeshProUGUI text, float lettersPerSecond, Action onCharacterTyped, Action onPauseStarted, Action onPauseEnded, Stack<(int position, float duration)> pausePositions, CoroutineInterruptToken stopToken = null)

Remarks

Essentially identical to Typewriter(TextMeshProUGUI,float,Action,CoroutineInterruptToken) but supports pausing the animation based on pausePositions values.

This method works by adjusting the value of the text parameter's TextMeshProUGUI.maxVisibleCharacters property. This means that word wrapping will not change half-way through the presentation of a word.

Depending on the value of lettersPerSecond, onCharacterTyped may be called multiple times per frame.

Due to an internal implementation detail of TextMeshProUGUI, this method will always take at least one frame to execute, regardless of the length of the text parameter's text.

Name
Description

FadeAlpha(CanvasGroup,float,float,float,CoroutineInterruptToken)

Method in Effects

Summary

A coroutine that fades a UnityEngine.CanvasGroup object's opacity from from to to over the course of fadeTime seconds, and then invokes onComplete .

public static IEnumerator FadeAlpha(CanvasGroup canvasGroup, float from, float to, float fadeTime, CoroutineInterruptToken stopToken = null)

Parameters

Name
Description

TMPro.TextMeshProUGUI text

A TextMeshProUGUI object to reveal the text of

float lettersPerSecond

The number of letters that should be revealed per second.

Parameters

float from

The opacity value to start fading from, ranging from 0 to 1.

float to

The opacity value to end fading at, ranging from 0 to 1.

stopToken

A that can be used to interrupt the coroutine.

UnityEngine.CanvasGroup canvasGroup

System.Action onCharacterTyped

An System.Action that should be called for each character that was revealed.

System.Action onPauseStarted

An System.Action that will be called when the typewriter effect is paused.

System.Action onPauseEnded

An System.Action that will be called when the typewriter effect is restarted.

System.Collections.Generic.Stack<(int position, float duration)> pausePositions

A stack of character position and pause duration tuples used to pause the effect. Generally created by GetPauseDurationsInsideLine(Markup.MarkupParseResult)

Yarn.Unity.Effects.CoroutineInterruptToken stopToken

A CoroutineInterruptToken that can be used to interrupt the coroutine.

float fadeTime

Yarn.Unity.Effects.CoroutineInterruptToken
CoroutineInterruptToken

Typewriter(TextMeshProUGUI,float,Action,CoroutineInterruptToken)

Method in Effects

Summary

A coroutine that gradually reveals the text in a TMPro.TextMeshProUGUI object over time.

public static IEnumerator Typewriter(TextMeshProUGUI text, float lettersPerSecond, Action onCharacterTyped, CoroutineInterruptToken stopToken = null)

Remarks

This method works by adjusting the value of the text parameter's TextMeshProUGUI.maxVisibleCharacters property. This means that word wrapping will not change half-way through the presentation of a word.

Depending on the value of lettersPerSecond, onCharacterTyped may be called multiple times per frame.

Due to an internal implementation detail of TextMeshProUGUI, this method will always take at least one frame to execute, regardless of the length of the text parameter's text.

Parameters

Name
Description

TMPro.TextMeshProUGUI text

A TextMeshProUGUI object to reveal the text of.

float lettersPerSecond

The number of letters that should be revealed per second.

System.Action onCharacterTyped

An System.Action that should be called for each character that was revealed.

stopToken

A that can be used to interrupt the coroutine.

Yarn.Unity.Effects.CoroutineInterruptToken
CoroutineInterruptToken

WasInterrupted

Property in

public bool WasInterrupted { get };

Summary

CoroutineInterruptToken

CanInterrupt

Property in

public bool CanInterrupt { get };

Summary

CoroutineInterruptToken