Class TMPAnimator
- Namespace
- TMPEffects.Components
Animates the character of a TMP_Text component.
public class TMPAnimator : TMPEffectComponent
- Inheritance
-
TMPAnimator
- Inherited Members
Remarks
One of the two main components of TMPEffects, along with TMPWriter.
TMPAnimator allows you to apply animations to the characters of a TMP_Text component.
There are three types of animations:
- TMPAnimation: The "basic" type of animation. Will animate the effected text continuously.
- TMPShowAnimation: Will animate the effected text when it begins to be shown. Show animations are only applied if there is also a TMPWriter component on the same GameObject.
- TMPHideAnimation: Will animate the effected text when it begins to be hidden. Hide animations are only applied if there is also a TMPWriter component on the same GameObject.
You may control when the animations are updated by setting UpdateFrom to Script and calling UpdateAnimations(float).
Fields
ANIMATION_PREFIX
The prefix used for basic animation tags.
public const char ANIMATION_PREFIX = '\0'
Field Value
HIDE_ANIMATION_PREFIX
The prefix used for hide animation tags.
public const char HIDE_ANIMATION_PREFIX = '-'
Field Value
SHOW_ANIMATION_PREFIX
The prefix used for show animation tags.
public const char SHOW_ANIMATION_PREFIX = '+'
Field Value
Properties
AnimateOnStart
Whether the TMPAnimator should automatically begin animating on TMPEffects.Components.TMPAnimator.Start().
public bool AnimateOnStart { get; set; }
Property Value
AnimationsOverride
Whether animations will override each other by default.
public bool AnimationsOverride { get; set; }
Property Value
AnimatorContext
The context used by this animator.
public IAnimatorContext AnimatorContext { get; }
Property Value
BasicTags
All basic animation tags parsed by the TMPAnimator.
public ITagCollection BasicTags { get; }
Property Value
Database
The database used to parse animation tags.
public TMPAnimationDatabase Database { get; }
Property Value
HideTags
All hide animation tags parsed by the TMPAnimator.
public ITagCollection HideTags { get; }
Property Value
IsAnimating
Whether the text is currently being animated.
If UpdateFrom is set to Script, this will always evaluate to true.
public bool IsAnimating { get; }
Property Value
KeywordDatabase
The keyword database used to parse tag parameters.
public ITMPKeywordDatabase KeywordDatabase { get; }
Property Value
SceneAnimations
The TMPSceneAnimation used by this animator.
public IDictionary<string, TMPSceneAnimation> SceneAnimations { get; }
Property Value
SceneHideAnimations
The TMPSceneHideAnimation used by this animator.
public IDictionary<string, TMPSceneHideAnimation> SceneHideAnimations { get; }
Property Value
SceneShowAnimations
The TMPSceneShowAnimation used by this animator.
public IDictionary<string, TMPSceneShowAnimation> SceneShowAnimations { get; }
Property Value
ShowTags
All show animation tags parsed by the TMPAnimator.
public ITagCollection ShowTags { get; }
Property Value
Tags
All tags parsed by the TMPAnimator.
public ITagCollection Tags { get; }
Property Value
UpdateFrom
Where the animations are currently being updated from.
public UpdateFrom UpdateFrom { get; }
Property Value
Methods
IsExcluded(char, TMPAnimationType)
Whether the character is excluded from animations of the given type.
public bool IsExcluded(char c, TMPAnimationType type)
Parameters
c
charThe character to check.
type
TMPAnimationTypeThe type of animation to check against.
Returns
- bool
Whether the character is excluded from animations of the given type.
Exceptions
- ArgumentException
If an invalid TMPAnimationType is passed in.
IsExcludedBasic(char)
Check whether the given character is excluded from basic animations.
public bool IsExcludedBasic(char c)
Parameters
c
charThe character to check.
Returns
- bool
Whether the character is excluded from basic animations.
IsExcludedHide(char)
Check whether the given character is excluded from hide animations.
public bool IsExcludedHide(char c)
Parameters
c
charThe character to check.
Returns
- bool
Whether the character is excluded from hide animations.
IsExcludedShow(char)
Check whether the given character is excluded from show animations.
public bool IsExcludedShow(char c)
Parameters
c
charThe character to check.
Returns
- bool
Whether the character is excluded from show animations.
QueueCharacterReset()
Queue a character reset.
All animated characters will be reset to their initial state before the next animation update.
public void QueueCharacterReset()
RegisterPostAnimationHook(OnCharacterAnimatedEventHandler)
Register a post-animation hook. The passed in method will be called whenever a character has been animated,
allowing you to make additional modifications to the character.
This is primarily useful for non-continuous animations, e.g. when you want a character to jump up whenever a sound plays.
public void RegisterPostAnimationHook(TMPAnimator.OnCharacterAnimatedEventHandler handler)
Parameters
handler
TMPAnimator.OnCharacterAnimatedEventHandlerThe post-animation hook method.
ResetAnimations()
Reset all visible characters to their initial, unanimated state.
public void ResetAnimations()
ResetTime(float)
Reset the time of the animator.
The time value to set the animator to. 0 by default, must be positive.public void ResetTime(float time = 0)
Parameters
time
float
SetDatabase(TMPAnimationDatabase)
Set the database that will be used to parse animation tags.
public void SetDatabase(TMPAnimationDatabase database)
Parameters
database
TMPAnimationDatabaseThe database that will be used to parse animation tags.
SetExcludedBasicCharacters(string, bool?)
Set the excluded character for basic animations, meaning characters that will not be animated by basic animations.
public void SetExcludedBasicCharacters(string str, bool? excludePunctuation = null)
Parameters
str
stringThe excluded characters, as string. The string will be evaluated character-wise.
excludePunctuation
bool?Whether punctuation is excluded.
SetExcludedCharacters(TMPAnimationType, string, bool?)
Set the excluded character for animations of the given type, meaning characters that will not be animated by that type of animations.
public void SetExcludedCharacters(TMPAnimationType type, string str, bool? excludePunctuation = null)
Parameters
type
TMPAnimationTypestr
stringThe excluded characters, as string. The string will be evaluated character-wise.
excludePunctuation
bool?Whether punctuation is excluded.
Exceptions
- ArgumentException
If an invalid TMPAnimationType is passed in.
SetExcludedHideCharacters(string, bool?)
Set the excluded character for hide animations, meaning characters that will not be animated by hide animations.
public void SetExcludedHideCharacters(string str, bool? excludePunctuation = null)
Parameters
str
stringThe excluded characters, as string. The string will be evaluated character-wise.
excludePunctuation
bool?Whether punctuation is excluded.
SetExcludedShowCharacters(string, bool?)
Set the excluded character for show animations, meaning characters that will not be animated by show animations.
public void SetExcludedShowCharacters(string str, bool? excludePunctuation = null)
Parameters
str
stringThe excluded characters, as string. The string will be evaluated character-wise.
excludePunctuation
bool?Whether punctuation is excluded.
SetKeywordDatabase(TMPKeywordDatabase)
Set the keyword database that will be used to parse tags.
public void SetKeywordDatabase(TMPKeywordDatabase database)
Parameters
database
TMPKeywordDatabaseThe 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
TMPSceneKeywordDatabaseThe database that will be used to parse tags.
SetUpdateFrom(UpdateFrom)
Set where the animations should be updated from.
public void SetUpdateFrom(UpdateFrom updateFrom)
Parameters
updateFrom
UpdateFromWhere the animations are updated from.
StartAnimating()
Start animating.
You should only call this if UpdateFrom is NOT set to Script,
otherwise this will output a warning and return.
public void StartAnimating()
StopAnimating()
Stop animating.
You should only call this if UpdateFrom is NOT set to Script,
otherwise this will output a warning and return.
public void StopAnimating()
UnregisterPostAnimationHook(OnCharacterAnimatedEventHandler)
Unregister a post-animation hook that was registered using RegisterPostAnimationHook(OnCharacterAnimatedEventHandler).
public bool UnregisterPostAnimationHook(TMPAnimator.OnCharacterAnimatedEventHandler handler)
Parameters
handler
TMPAnimator.OnCharacterAnimatedEventHandlerThe post-animation hook method.
Returns
- bool
true if handler is successfully removed; otherwise, false. This method also returns false if handler was not registered.
UpdateAnimations(float)
Update the current animations.
You should only call this if UpdateFrom is set to Script,
otherwise this will output a warning and return.
public void UpdateAnimations(float deltaTime)
Parameters
deltaTime
float