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
-
ObjectComponentBehaviourMonoBehaviourTMPWriter
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.transformComponent.gameObjectComponent.tagObject.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.nameObject.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:
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
EVENT_PREFIX
The prefix used for event tags.
public const char EVENT_PREFIX = '?'
Field Value
OnCharacterShown
Raised when the TMPWriter shows a new character.
public UnityEvent<TMPWriter, CharData> OnCharacterShown
Field Value
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
OnSkipWriter
Raised when the current (section of) text is skipped.
public UnityEvent<TMPWriter, int> OnSkipWriter
Field Value
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
Properties
CommandTags
All command tags parsed by the TMPWriter.
public ITagCollection CommandTags { get; }
Property Value
CurrentDelays
public TMPWriter.Delays CurrentDelays { get; }
Property Value
CurrentIndex
The text index of the TMPWriter's current character.
public int CurrentIndex { get; }
Property Value
Database
The database used to parse command tags.
public TMPCommandDatabase Database { get; }
Property Value
DefaultDelays
public TMPWriter.Delays DefaultDelays { get; }
Property Value
EventTags
All event tags parsed by the TMPWriter.
public ITagCollection EventTags { get; }
Property Value
IsWriting
Whether the TMPWriter is currently writing text.
public bool IsWriting { get; }
Property Value
MaySkip
Whether the TMPWriter may skip the current section of text.
public bool MaySkip { get; }
Property Value
Tags
All tags parsed by the TMPWriter.
public ITagCollection Tags { get; }
Property Value
UseScaledTime
public bool UseScaledTime { get; set; }
Property Value
WriteOnNewText
public bool WriteOnNewText { get; set; }
Property Value
WriteOnStart
public bool WriteOnStart { get; set; }
Property Value
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
intThe 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
TMPCommandDatabaseThe 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
boolWhether 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
floatThe 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)