Show and hide letters dynamically

You can use a Typewriter to show and hide letters dynamically, choosing different pauses for any kind of characters (punctuation, letters, […]), trigger events and more.


Showing Text

The typewriter contains general settings and events listeners, and allows for different pauses/timing modes:

  • By Character: shows one letter after the other.

  • By Word: progresses text word after word.

Your typewriter should look like this:

From the TypewriterComponent in the Inspector:


You can start the typewriter in two main ways:

If you want to use the typewriter, it is recommended that you set the text directly to that component via code.

If you are using TextMeshPro, please replace scripts that reference TMPro or Text Animator (Setting up texts) and reference Febucci.TextAnimatorForUnity.TypewriterComponent instead.

  • Don't: “tmproText.text = textValue;” , or "textAnimator.SetText(textValue);"

  • Do: typewriter.ShowText(textValue);

B) Automatic recognition

In case you haven't followed the step above, TextAnimator will still try to start the typewriter automatically if you have added a Typewriter component or have set up "Timings" through the AnimatedLabel in UI Toolkit.


Controlling Letters

Start and Stop Typing

Inside the component’s Inspector you’ll find some options to control how the typewriter start should be triggered:

  • Start Typewriter Mode: tells the typewriter when to start showing letters.

Value
Explanation

From Script Only

The typerwiter can only be started by invoking TextAnimatorPlayer.StartShowingText()

OnEnable

The typewriter starts every time the gameObject is set active

OnShowText

The typewriter starts as soon as a new text is set (as explained in the “Showing Text” section)

Automatically From All Events

All of the above

  • Reset Typing Speed At Startup: true if you want the typewriter’s speed to reset back to 1 every time a new text is show, otherwise it will save the last one used.

Skip the Entire Text

To Skip the entire typewriter, you can invoke the typewriter.SkipTypewriter() method.

You can also find a few options to control how it behaves:

  • Hide Appearances On Skip: true if you want to prevent appearance effects from playing whenever the typewriter skips (meaning that the text will be shown instantly).

  • Trigger Events On Skip: true if you want to trigger all remaining events once the typewriter skips (be careful with that if you’re running some game logic with them, as everything will be run at once). Read more about events here: Trigger Events when typing

Skip Specific Parts of the Text

Hiding Text

You can hide letters dynamically via script, by invoking typewriter.StartDisappearingText(), and you can also stop it at any time by invoking typewriter.StopDisappearingText().


You can create your own timing waits (read here how via C#) or you can use the built-in ones.

Options

Typewriters might share the same settings and also have specific ones, so be sure to hover the mouse cursor above its fields in the Inspector to show the tooltips for each one.

Here is a quick overview of the most important/common ones:

Callbacks (Unity Events)

You can use Unity Events that will be triggered based on the typewriter activity (example: when it just ended showing text).

Event
Explanation

OnTextShowed

Event called after the entire text has been shown (if you’ve set “Use Typewriter” to true, it will wait until all letters are shown)

OnTextDisappeared

Called as soon as the script starts hiding the last letter

The following below only work if the “use typewriter” is set to true:

Event
Explanation

OnTypewriterStart

Called right before the typewriter starts showing its first letter. It doesn’t work if the typewriter is off, since it would coincide with the “OnTextShowed” event (in this case you can use that one instead)

OnCharacterVisible(Char)

Called each time a character became visible

OnMessage(EventMarker)

Invoked every time the typewriter meets a message/event in text. Read more about events here

A typewriter uses its linked Text Animator Time Scale to progress time (you can read more here: Time Scale), meaning that if the time is set to "Unscaled", then the typewriter will progress even if your game is paused.