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.
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);
}
}That’s it!
Don’t forget to create the scriptable object in your assets folder, and to assign it to your Typewriter component. Read more here: Show and hide letters dynamically
Have fun implementing your own typewriters <3