Show and hide letters dynamically
Last updated
Last updated
You can use Typewriters
to show and hide letters dynamically, choosing different pauses for any kind of characters (punctuation, letters, […]), trigger events and more.
A typewriter uses its linked Text Animator Time Scale to progress time, you can read more here: Time Scale
There are different types of typewriters, for example “By Character
” which shows one letter after the other, or “By Word
” which progresses text word after word.
After choosing which Typewriter to use (which means: after adding the component on the same GameObject that has a "TextAnimator" one), you can start it in two main ways:
Replacing “tmproText.text = textValue;
” with typewriter.ShowText(textValue);
in your code (Scripting API).
Please don't miss this step if you're setting the text via code! If you're having issues, take a look at the Best Practices
Enabling the “Typewriter Starts Automatically
” option in the TextAnimator component (p.s. this was previously called “Easy Integration”).
This will let the plugin automatically check for text changes from your TextMeshPro’s component and start the typewriter based on it.
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.
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.
You can pause the typewriter at any time by invoking typewriter.StopShowingText(), and you can start/resume it by invoking typewriter.StartShowingText().
You can also test this in Play Mode from the Inspector (the buttons are only greyed out in Edit Mode).
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
You can use the "<notype>
" tag to skip the typewriter under specific sections of the text. For example "Hello <notype>I am shown instantly</notype> and now I'm typing normally again.
"
You can also change this tag in the global settings, in case you prefer to set a different one.
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 also test this during runtime through the buttons in the Inspector.
You can create your own typewriter (read here how to create a custom typewriter via C#) or you can use the built-in one.
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:
You can use Unity Events that will be triggered based on the typewriter activity (example: when it just ended showing text).
The following below only work if the “use typewriter” is set to true:
You can hover the mouse above the typewriter options (e.g. delays) to show some tooltips and extra information!
Value | Explanation |
---|---|
Event | Explanation |
---|---|
Event | 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
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
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