Writing Custom Effects C#
Last updated
Last updated
You're reading the documentation of an older/legacy version, Text Animator 1.X. To read the latest version, please visit this page insteadΒ . How to update:
In this guide you'll learn how to create your own custom effects via C#. P.s. In case you want to create effects from the inspector, please take a look at the "Creating Effects in the Inspector" page.
TextAnimator has different type of effects, Behaviors and Appearances/Disappearances. You can create a class for your effect and inherit from the base class of an effect category.
AppearanceBase for appearance and disappearance effects. Reminder: Disappearance effects are "Appearances" in reverse, so you can create an appearance one and have both automatically.
BehaviorBase for behavior effects.
To assign a tag to your effect, simply add the EffectInfo attribute to your class.
Be sure to also add the "UnityEngine.Scripting.Preserve" attribute (as you see in the above example), in order to prevent the compiler to strip the class from the build.
In the above example, the effect will be applied if you write <jump> as rich text tag in the text.
Each effect class has to implement a few methods in order to work. You can find the abstract methods (and also some virtual ones that can help you) in their scripting api section.
EffectBase methods, for all the effects
Appearance methods, only for Appearance and Disappearance effects
Behavior methods, only for Behavior effects
ππ» You can also take a look at the built-in effects classes and see how they're implemented.
You've completed all the steps necessary, yay! The more effects you add, the more this process will sound familiar and simpler.
Have fun applying your effects!