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: Febucci.TextAnimator.Runtime.dll
Syntax
public class TextAnimator : MonoBehaviour
Fields
effectIntensityMultiplier
Multiplies the intensity for all the effects that behave differently with fonts and sizes.
Declaration
public float effectIntensityMultiplier
Field Value
Type | Description |
---|---|
Single |
isResettingEffectsOnNewText
True if you want effects time to be reset when a new text is set (default option), false otherwise.
Declaration
public bool isResettingEffectsOnNewText
Field Value
Type | Description |
---|---|
Boolean |
referenceFontSize
Used for scaling, represents the text's size where/when effects intensity behave like intended.
Declaration
public float referenceFontSize
Field Value
Type | Description |
---|---|
Single |
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 |
updateMode
Controls how Text Animator should update its effects. Set to Manual in order to update effects manually from script, invoking UpdateEffects().
Declaration
public TextAnimator.UpdateMode updateMode
Field Value
Type | Description |
---|---|
TextAnimator.UpdateMode |
useDynamicScaling
True if you want effects to have the same intensities even if text is larger/smaller than default (example: when TMPro's AutoSize changes the size based on screen size)
Declaration
public bool useDynamicScaling
Field Value
Type | Description |
---|---|
Boolean |
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.
anyLetterVisible
true
if any letter is still visible in the text
Declaration
public bool anyLetterVisible { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
You can use this to check if the disappearance effects are still running.
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)
firstVisibleCharacter
Declaration
public int firstVisibleCharacter { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
latestCharacterShown
The latest TextMeshPro character shown by the typewriter.
Declaration
public TMP_CharacterInfo latestCharacterShown { get; }
Property Value
Type | Description |
---|---|
TMPro.TMP_CharacterInfo |
maxVisibleCharacters
Declaration
public int maxVisibleCharacters { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
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 |
|
Remarks
If you're using the typewriter, you must manually start it from the code (after appending the text). See: StartShowingText(Boolean)
AssignSharedAppearancesData(BuiltinAppearancesDataScriptable)
Declaration
public void AssignSharedAppearancesData(BuiltinAppearancesDataScriptable scriptable)
Parameters
Type | Name | Description |
---|---|---|
Febucci.UI.Core.BuiltinAppearancesDataScriptable | scriptable |
AssignSharedBehaviorsData(BuiltinBehaviorsDataScriptable)
Declaration
public void AssignSharedBehaviorsData(BuiltinBehaviorsDataScriptable scriptable)
Parameters
Type | Name | Description |
---|---|---|
Febucci.UI.Core.BuiltinBehaviorsDataScriptable | scriptable |
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()
ResetEffectsTime(Boolean)
Resets the effects time, making them start from the start.
Declaration
public void ResetEffectsTime(bool skipAppearances)
Parameters
Type | Name | Description |
---|---|---|
Boolean | skipAppearances | if you want the characters to reset mostly their behavior effects, staying on screen. if you want all characters to disappear and play back from their appearance (all together).
|
Remarks
P.S. If you want to restart the typewriter, see StartShowingText(Boolean)
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()
TriggerVisibleEvents()
Triggers events that are currently visible
Declaration
public void TriggerVisibleEvents()
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))
{
///[...]
}
UpdateEffects()
Invoke this to manually update the effects, when updateMode is set to Manual.
Declaration
public void UpdateEffects()
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 |