Class TextAnimator
The main TextAnimator component. Add this near to a TextMeshPro component in order to enable effects. It can also be used in combination with a TextAnimatorPlayer in order to display letters dynamically (like a typewriter).
- See also: TextAnimatorPlayer
- Manual: How to add effects to your texts
Inheritance
Namespace: Febucci.UI
Assembly: Assembly-CSharp-firstpass.dll
Syntax
public class TextAnimator : MonoBehaviour
Fields
timeScale
Effects timescale, you can set it to scaled or unscaled. It also affects the TextAnimatorPlayer, if there is one linked to this TextAnimator.
Declaration
public TextAnimator.TimeScale timeScale
Field Value
Type | Description |
---|---|
TextAnimator.TimeScale |
Properties
allLettersShown
true
if the text is entirely visible.
Declaration
public bool allLettersShown { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
You can use this to check if all the letters have been shown.
effectsAppearancesEnabled
true
if appearance effects are enabled globally (in all TextAnimators).
Declaration
public static bool effectsAppearancesEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
To modify this value, invoke: EnableAppearances(Boolean)
effectsBehaviorsEnabled
true
if behavior effects are enabled globally (in all TextAnimators).
Declaration
public static bool effectsBehaviorsEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
To modify this value, invoke: EnableBehaviors(Boolean)
latestCharacterShown
The latest TextMeshPro character shown by the typewriter.
Declaration
public TMP_CharacterInfo latestCharacterShown { get; }
Property Value
Type | Description |
---|---|
TMPro.TMP_CharacterInfo |
text
The text stored in the TextAnimator component, without TextAnimator's tags.
Declaration
public string text { get; }
Property Value
Type | Description |
---|---|
String |
time
Contains TextAnimator's current time values.
Declaration
public TextAnimator.TimeData time { get; }
Property Value
Type | Description |
---|---|
TextAnimator.TimeData |
tmproText
The TextMeshPro component linked to this TextAnimator
Declaration
public TMP_Text tmproText { get; }
Property Value
Type | Description |
---|---|
TMPro.TMP_Text |
Methods
AppendText(String, Boolean)
Appends the given text to the already existing TMPro's one, applying its tags etc.
Declaration
public void AppendText(string text, bool hideText)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to append, including rich text tags |
Boolean | hideText |
|
EnableAllEffects(Boolean)
Enables/Disables all effects for all TextAnimators.
Declaration
public static void EnableAllEffects(bool enabled)
Parameters
Type | Name | Description |
---|---|---|
Boolean | enabled |
EnableAppearances(Boolean)
Enables/Disables Appearances effects globally (for all TextAnimators)
Declaration
public static void EnableAppearances(bool enabled)
Parameters
Type | Name | Description |
---|---|---|
Boolean | enabled |
Remarks
To check if behaviors are enabled, refer to effectsAppearancesEnabled
EnableAppearancesLocally(Boolean)
Enables/disables Appearance effects for this specific TextAnimator component.
Declaration
public void EnableAppearancesLocally(bool value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | value |
Remarks
To disable effects on all TextAnimators, please see EnableAppearances(Boolean)
EnableBehaviors(Boolean)
Enables/Disables Behavior effects globally (for all TextAnimators)
Declaration
public static void EnableBehaviors(bool enabled)
Parameters
Type | Name | Description |
---|---|---|
Boolean | enabled |
Remarks
To check if behaviors are enabled, refer to effectsBehaviorsEnabled
EnableBehaviorsLocally(Boolean)
Enables/disables Behavior effects for this specific TextAnimator component.
Declaration
public void EnableBehaviorsLocally(bool value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | value |
Remarks
To disable effects on all TextAnimators, please see EnableAppearances(Boolean)
ForceMeshRefresh()
Forces refreshing the mesh at the end of the frame
Declaration
public void ForceMeshRefresh()
IncreaseVisibleChars()
Increases the visible characters count in the text. It also triggers events (if any)
Declaration
public char IncreaseVisibleChars()
Returns
Type | Description |
---|---|
Char | Returns the latest shown character |
SetText(String, Boolean)
Method to set the TextAnimator's text and apply its tags (effects/actions/tmpro/...).
Declaration
public void SetText(string text, bool hideText)
Parameters
Type | Name | Description |
---|---|---|
String | text | Source text, including rich text tags |
Boolean | hideText |
|
ShowAllCharacters(Boolean)
Turns all characters visible at the end of the frame (i.e. "a typewriter skip")
Declaration
public void ShowAllCharacters(bool skipAppearanceEffects)
Parameters
Type | Name | Description |
---|---|---|
Boolean | skipAppearanceEffects | Set this to true if you want all letters to appear instantly (without any appearance effect) |
TriggerRemainingEvents()
Triggers all the remaining TextAnimator's events.
Declaration
public void TriggerRemainingEvents()
TryGetNextCharacter(out TMP_CharacterInfo)
Tries to return the next character in the text.
Declaration
public bool TryGetNextCharacter(out TMP_CharacterInfo result)
Parameters
Type | Name | Description |
---|---|---|
TMPro.TMP_CharacterInfo | result |
Returns
Type | Description |
---|---|
Boolean |
Examples
if (textAnimatorComponent.TryGetNextCharacter(out TMP_CharacterInfo nextChar))
{
///[...]
}
Events
onEvent
Invoked by the typewriter once it reaches a message tag while showing letters.
- Manual: Triggering Events while typing
Declaration
public event TextAnimator.MessageEvent onEvent
Event Type
Type | Description |
---|---|
TextAnimator.MessageEvent |