Text Animator for Unity
More ToolsTutorialsDiscord✨ Get Text Animator ✨
1.X πŸ‡¬πŸ‡§
1.X πŸ‡¬πŸ‡§
  • Installing and quick start
  • Effects
    • How to add effects to your texts
    • Built In Effects List
    • Creating effects in the inspector
  • Typewriter
    • Text Animator Players
    • Triggering Events While Typing
    • Performing Actions While Typing
    • Text Animator Players Sound
  • Extra Customization
    • Writing Custom Effects C#
    • Writing Custom Actions C#
    • Writing Custom TAnimPlayers (C#)
  • Integrations
    • Integrated Plugins & Dialogue Systems
    • How to manually integrate Text Animator
  • Info
    • Support
    • Changelog
Powered by GitBook
On this page
  • 1. Effect Base Class
  • 2. Effect Tag
  • 3. Override Methods
  • βœ… Done!
  1. Extra Customization

Writing Custom Effects C#

PreviousText Animator Players SoundNextWriting Custom Actions C#

Last updated 7 months ago

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.


1. Effect Base Class

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.

public class JumpAppearance : AppearanceBase //<--- for appearance effects and disappearances
{
    //[...]

BehaviorBase for behavior effects.

public class JumpBehavior : BehaviorBase //<--- for behavior effects
{
    //[...]

2. Effect Tag

To assign a tag to your effect, simply add the EffectInfo attribute to your class.

[Febucci.UI.Core.EffectInfo(tag: "jump")]
[UnityEngine.Scripting.Preserve] 
public class JumpBehavior : BehaviorBase
{
    //[...]

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.

3. Override Methods

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.

βœ… Done!

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!

2.X πŸ‡¬πŸ‡§
Upgrading from 1.X to 2.X