Table of Contents

Class TMPWriter

Namespace
TMPEffects.Components
Assembly
TMPEffects.dll

Shows / hides the characters of a TMPro.TMP_Text component over time,
and allows you to raise events and commands at specific indices.

[HelpURL("https://tmpeffects.luca3317.dev/docs/tmpwriter.html")]
[ExecuteAlways]
[DisallowMultipleComponent]
[RequireComponent(typeof(TMP_Text))]
public class TMPWriter : TMPEffectComponent
Inheritance
Object
Component
Behaviour
MonoBehaviour
TMPWriter
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.transform
Component.gameObject
Component.tag
Object.GetInstanceID()
Object.GetHashCode()
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Remarks

One of the two main components of TMPEffects, along with TMPAnimator.
Using command tags, you can call specific methods. There are two types of Commands:

In additon to command tags, TMPWriter also processes event tags:

TMPEvent: Using event tags, you can raise events from text, i.e. when a specific character is shown. You can subscribe to these events with OnTextEvent.

Fields

COMMAND_PREFIX

The prefix used for command tags.

public const char COMMAND_PREFIX = '!'

Field Value

char

EVENT_PREFIX

The prefix used for event tags.

public const char EVENT_PREFIX = '?'

Field Value

char

OnCharacterShown

Raised when the TMPWriter shows a new character.

public UnityEvent<TMPWriter, CharData> OnCharacterShown

Field Value

UnityEvent<TMPWriter, CharData>

OnFinishWriter

Raised when the TMPWriter is done writing the current text.

public UnityEvent<TMPWriter> OnFinishWriter

Field Value

UnityEvent<TMPWriter>

OnResetWriter

Raised when the TMPWriter is reset.
The integer parameter indicates the text index the TMPWriter was reset to.

public UnityEvent<TMPWriter, int> OnResetWriter

Field Value

UnityEvent<TMPWriter, int>

OnSkipWriter

Raised when the current (section of) text is skipped.

public UnityEvent<TMPWriter, int> OnSkipWriter

Field Value

UnityEvent<TMPWriter, int>

OnStartWriter

Raised when the TMPWriter starts / resumes writing.

public UnityEvent<TMPWriter> OnStartWriter

Field Value

UnityEvent<TMPWriter>

OnStopWriter

Raised when the TMPWriter stops writing.

public UnityEvent<TMPWriter> OnStopWriter

Field Value

UnityEvent<TMPWriter>

OnTextEvent

Raised when the TMPWriter reaches an event tag.

public TMPEvent OnTextEvent

Field Value

TMPEvent

Properties

CommandTags

All command tags parsed by the TMPWriter.

public ITagCollection CommandTags { get; }

Property Value

ITagCollection

CurrentDelays

public TMPWriter.Delays CurrentDelays { get; }

Property Value

TMPWriter.Delays

CurrentIndex

The text index of the TMPWriter's current character.

public int CurrentIndex { get; }

Property Value

int

Database

The database used to parse command tags.

public TMPCommandDatabase Database { get; }

Property Value

TMPCommandDatabase

DefaultDelays

public TMPWriter.Delays DefaultDelays { get; }

Property Value

TMPWriter.Delays

EventTags

All event tags parsed by the TMPWriter.

public ITagCollection EventTags { get; }

Property Value

ITagCollection

IsWriting

Whether the TMPWriter is currently writing text.

public bool IsWriting { get; }

Property Value

bool

MaySkip

Whether the TMPWriter may skip the current section of text.

public bool MaySkip { get; }

Property Value

bool

Tags

All tags parsed by the TMPWriter.

public ITagCollection Tags { get; }

Property Value

ITagCollection

UseScaledTime

public bool UseScaledTime { get; set; }

Property Value

bool

WriteOnNewText

public bool WriteOnNewText { get; set; }

Property Value

bool

WriteOnStart

public bool WriteOnStart { get; set; }

Property Value

bool

Methods

ResetWaitConditions()

public void ResetWaitConditions()

ResetWaitPeriod()

public void ResetWaitPeriod()

ResetWriter()

Reset the writer to the initial state for the current text.
This also stops the writing process.

public void ResetWriter()

ResetWriter(int)

Reset the writer to the given index of the current text.
Does not allow you to skip text; the passed index must be smaller than the current index.

public void ResetWriter(int index)

Parameters

index int

The index to reset the writer to.

RestartWriter()

Restart the writer.
This will reset the writer and start the writing process.

public void RestartWriter()

SetDatabase(TMPCommandDatabase)

Set the database that will be used to parse command tags.

public void SetDatabase(TMPCommandDatabase database)

Parameters

database TMPCommandDatabase

The database that will be used to parse command tags.

SetSkippable(bool)

Set whether the current text may be skipped.

public void SetSkippable(bool skippable)

Parameters

skippable bool

Whether the current text may be skipped.

SkipWriter(bool)

Skip the current section of the text.
If the current section may not be skipped, this will do nothing.
Otherwise, the writing process is skipped to either the end of the current text, or the next unskippable section of the current text.

public void SkipWriter(bool skipShowAnimation = true)

Parameters

skipShowAnimation bool

StartWriter()

Start (or resume) writing.

public void StartWriter()

StopWriter()

Stop writing.
Note that this does not reset the shown text.

public void StopWriter()

Wait(float)

Pause the writer for the given amount of seconds.

public void Wait(float seconds)

Parameters

seconds float

The amount of time to wait.

Exceptions

ArgumentOutOfRangeException

Throws if seconds is less than zero.

WaitUntil(Func<bool>)

Pause the writer until the given condition evaluates to true.

public void WaitUntil(Func<bool> condition)

Parameters

condition Func<bool>

The condition to wait for.