Table of Contents

Class TMPWriter

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

public class TMPWriter : TMPEffectComponent
Inheritance
TMPWriter
Inherited Members

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 addition 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

OnWaitEnded

Raised when the TMPWriter ends waiting.

public UnityEvent<TMPWriter> OnWaitEnded

Field Value

UnityEvent<TMPWriter>

OnWaitStarted

Raised when the TMPWriter starts waiting. The float parameter indicates the amount of time the TMPWriter will wait, in seconds.

public UnityEvent<TMPWriter, float> OnWaitStarted

Field Value

UnityEvent<TMPWriter, float>

Properties

CommandTags

All command tags parsed by the TMPWriter.

public ITagCollection CommandTags { get; }

Property Value

ITagCollection

CurrentDelays

The current delays by the writer, influenced by modifying tags etc.

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

The default delays used by the writer.

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

KeywordDatabase

The keyword database used to parse tag parameters.

public ITMPKeywordDatabase KeywordDatabase { get; }

Property Value

ITMPKeywordDatabase

MaySkip

Whether the TMPWriter may skip the current section of text.

public bool MaySkip { get; }

Property Value

bool

SceneCommands

The TMPSceneCommandWrapper used by this writer.

public IDictionary<string, TMPSceneCommandWrapper> SceneCommands { get; }

Property Value

IDictionary<string, TMPSceneCommandWrapper>

Tags

All tags parsed by the TMPWriter.

public ITagCollection Tags { get; }

Property Value

ITagCollection

UseScaledTime

Whether to use scaled (Time.time) or unscaled time (Time.unscaledTime) for the writing process.

public bool UseScaledTime { get; set; }

Property Value

bool

WriteOnNewText

Whether to begin writing when the text of the associated TMP_Text component is changed.
Be aware that the TMP_Text component raises its TextChanged event it is first loaded as well.

public bool WriteOnNewText { get; set; }

Property Value

bool

WriteOnStart

Whether to begin writing when the TMPWriter's Start method is called (i.e. when it is first enabled).

public bool WriteOnStart { get; set; }

Property Value

bool

Methods

ResetWaitConditions()

Clear the conditions the writer should wait for (set using WaitUntil(Func<bool>).

public void ResetWaitConditions()

ResetWaitPeriod()

Reset the period the writer should pause for (set using Wait(float) to 0.

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.

SetKeywordDatabase(TMPKeywordDatabase)

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

public void SetKeywordDatabase(TMPKeywordDatabase database)

Parameters

database TMPKeywordDatabase

The database that will be used to parse tags.

SetSceneKeywordDatabase(TMPSceneKeywordDatabase)

Set the scene keyword database that will be used to parse tags.

public void SetSceneKeywordDatabase(TMPSceneKeywordDatabase database)

Parameters

database TMPSceneKeywordDatabase

The database that will be used to parse 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.