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
  • Adding Custom Typewriters
  • Fundamental Methods
  • Optional Methods
  1. Extra Customization

Writing Custom TAnimPlayers (C#)

PreviousWriting 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:


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, ).


Adding Custom Typewriters

In order to create a custom typewriter for your game, you need to to create a custom class that inherits from TAnimPlayerBase

Fundamental Methods

You have to override/implement the following methods.

float GetWaitAppearanceTimeOf(char character)

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

Example

protected override float GetWaitAppearanceTimeOf(char character)
{
    switch (character)
    {
        case ',': return 0.3f;

        case '!':
        case '?':
        case '.': return 0.6f;
    }

    return 0.1f;
}

IEnumerator WaitInput()

Waits for input in order to continue showing text.

Example:

protected override IEnumerator WaitInput()
{
	while (!Input.anyKeyDown)
		yield return null;
}

Optional Methods

You can also override the following methods for extra functionalities.

float GetWaitDisappearanceTimeOf(char character)

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);

IEnumerator DoCustomAction(TypewriterAction action)

Override this method to manage your custom actions. Read more here: Writing Custom Actions C#

virtual void OnTypeWriterStart()

Invoked every time the typewriter is starting to show the text. It doesn't fire up if the typewriter is set to false.


βœ… That's it!

Have fun implementing your own players <3

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