Writing Custom Typewriters (C#)

By using “Text Animator for Unity” you can create your own custom typewriters, setting different types of delays between letters and much more. (If you want to learn about the default typewriter instead, read here).


Adding Custom Typewriters

In order to create a custom typewriter for your game, you need to to create a custom class that inherits from Febucci.UI.Core.TypewriterCore [Scripting API].

Fundamental Methods

You have to override/implement the following methods:

float GetWaitAppearanceTimeOf(int charIndex)

It tells the typewriter how much time to wait for each character. This way, you can implement your own special characters that need an unique wait time and more.

You can access the character from the index by doing as follows:

char character = TextAnimator.Characters[charIndex].info.character

For example, in order to have a different wait time when typing punctuations:


[SerializeField] float normalTime = .1f;
[SerializeField] float punctuationTime = .3f;
protected override float GetWaitAppearanceTimeOf(int charIndex)
{
    char character = TextAnimator.Characters[charIndex].info.character;
    return char.IsPunctuation(character) ? punctuationTime : normalTime;
}

Optional Methods

You can also override the following methods for extra functionalities.

float GetWaitDisappearanceTimeOf(int charIndex)

Override this method in case you want different disappearance wait times/speed. Otherwise, your custom textAnimatorPlayer will use the same delays as its typewriter (GetWaitAppearanceTimeOf);


✅ That’s it! Really!

👍🏻 Don’t forget to add your typewriter component on the same gameObject that has a TextAnimator one.

Have fun implementing your own typewriters <3

Last updated