Table of Contents

TMPAnimator overview

This section gives an overview of the actual TMPAnimator component, both for the inspector and scripting. The full API documentation can be found here.

Preview

To toggle the editor preview of animations, press the TogglePreview at the top of the TMPAnimator inspector. Next to it, the button labeled Reset time resets the time tracked by the TMPAnimator component, and therefore all animations.

Updating the animations

In the inspector or through the SetUpdateFrom method, you can set how the animations are updated.

If UpdateFrom is set to either Update, LateUpdate or FixedUpdate, the animations are automatically updated in the respective Unity callback. In order to play animations in play mode, you will have to call StartAnimating or set the Play On Start to true in either the inspector or some other script's Awake function. You can then stop animating again by simply calling StopAnimating.

Alternatively, if you want more fine-tuned control over when and how often animations are updated, for example if you want to limit the updates per second to at most 300, you can set the TMPAnimator's UpdateFrom to Script. This causes the animations to no longer be updated automatically; instead you may call UpdateAnimations(float deltaTime) manually whenever you like.

Note that if UpdateFrom is set to Script, you should not call StartAnimating or StopAnimating, since this will have no effect besides logging a warning to Unity's console. Vice versa, if UpdateFrom is set to be automatically updated, you should not call UpdateAnimations(float deltaTime); it again does nothing but log a warning.

The state of UpdateFrom has no effect on the editor preview.

Animation databases

The TMPAnimator inspector has a foldout labeled Animations. There, you may choose the animation database that is used to process animation tags from the TextMeshPro component's text. If you toggle Use default database to true, the default animation database is automatically selected for you. The default database is defined in the TMPEffects preferences file. You can also set the database used by the TMPAnimator component through script, using the SetDatabase(TMPAnimationDatabase db) method.

Below the database, there are three other fields: SceneAnimations, SceneShowAnimations and SceneHideAnimations. These are simply dictionaries that allow you to map tag names to SceneAnimations. Tags defined here are also parsed by the TMPAnimator.

For more about databases, see Databases. For more about SceneAnimations, see SceneAnimations.

Animator settings

TMPAnimator has various settings that modify the way it animates its text. Each of these is settable through both the inspector and through script.

  • Animations override:
    The default override behavior for all animation tags. If true, each tag overrides any of its category (basic / show / hide) that came before it, and only that one is applied. Otherwise, animations are stacked by default. Each tag can manually define its override behavior by using the override (shorthand: or) parameter.

  • Default show / hide string:
    Allows you to define a default show / hide animation that is used for the entirety of the text, if no other show / hide animation tag effects it. Set this like you would add any tag to your text, e.g. <+fade dur=0.65 anc=a:bottom>>, <-spread crv=easeinoutsine>>.

  • Exclusions:
    For each of the animationg categories (basic / show / hide), you can define a set of characters that is excluded from all animations. For example, if you don't want numbers to be animated, you could set Excluded Characters to "1234567890". In addition to this, there is an Exclude Punctuation toggle for each of the categories.

  • Scale animations:
    Defines whether animations should be scaled to the font size property of the TMP_Text component. If true, animations will look identical regardless of font size.

  • Use scaled time:
    Defines whether animations should use scaled time or not.

Adding & removing tags through script

The TMPAnimator class exposes four different TagCollections: BasicTags, which contains all parsed basic animation tags, ShowTags, which contains all parsed show animation tags and HideTags, which contains all parsed hide animation tags. Additionally, Tags is the union of the other three collections.

For each of the TagCollections, you may freely add and remove tags at any point.