Writing Custom Typing Waits (C#)

By using “Text Animator for Unity” you can create your own custom typewriter waits, setting different types of delays between letters and much more.

If you want to learn about the default typewriter instead, read here

Be sure to have read the Advanced Concepts page as well.


Adding Custom Typewriter Waits

In order to create a custom typewriter wait you need to to create a Scriptable Object class that inherits from Febucci.TextAnimatorForUnity.TypingsTimingsScriptableBase

Here is a simple example script:

// import the necessary Febucci namespaces
using Febucci.TextAnimatorCore;
using Febucci.TextAnimatorCore.Text;
using Febucci.TextAnimatorForUnity;

using UnityEngine;

[System.Serializable] // <--- remember to serialize your scriptables!
[CreateAssetMenu(fileName = "Custom Typewriter Waits")]
class CustomTypingWaits : TypingsTimingsScriptableBase
{
    // --- put your properties here as normal
    [SerializeField] float delay = .1f;
    
    // custom waits when showing text
    public override float GetWaitAppearanceTimeOf(CharacterData character, TextAnimator animator)
    {
        // example: skips spaces
        if (char.IsWhiteSpace(character.info.character))
            return 0;

        return delay;
    }

    // custom waits when disappearing text
    public override float GetWaitDisappearanceTimeOf(CharacterData character, TextAnimator animator)
    {
        // in this case, it's the same as appearances
        return GetWaitAppearanceTimeOf(character, animator);
    }
}

Have fun implementing your own typewriters <3