3
2015
UI Text TypeWriter Effect [Script]

Quick & simple UI text typewriter effect (displays UI text 1 character at a time)
Assign to UI text component, it grabs the text from it at Awake() and clears it,
then starts to type out the text 1 character at a time.

| using UnityEngine; | |
| using System.Collections; | |
| using UnityEngine.UI; | |
| // attach to UI Text component (with the full text already there) | |
| public class UITextTypeWriter.cs : MonoBehaviour | |
| { | |
| Text txt; | |
| string story; | |
| void Awake () | |
| { | |
| txt = GetComponent<Text> (); | |
| story = txt.text; | |
| txt.text = ""; | |
| // TODO: add optional delay when to start | |
| StartCoroutine (PlayText()); | |
| } | |
| IEnumerator PlayText() | |
| { | |
| foreach (char c in story) | |
| { | |
| txt.text += c; | |
| yield return new WaitForSeconds (0.125f); | |
| } | |
| } | |
| } |
More versions, see comments:
https://gist.github.com/unitycoder/19625fed364a39cb278f
Related Posts
15 Comments + Add Comment
Leave a comment
Recent posts
- LudumDare59 : Signal
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
Recent Comments
- on Sprite Sheet Flip Book Shader
- on Sprite Sheet Flip Book Shader
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by












LifeSaver. thank you
Then where the link ? how can i download it??
Full script source is ^up there in the post,
but also here (someone has actually made improved version there with more options, see the comments on that page)
https://gist.github.com/unitycoder/19625fed364a39cb278f#file-uitexttypewriter-cs
[…] UI Text TypeWriter Effect | Unity Coding (unitycoder.com) […]
Really useful! Thanks!
[…] UI Text TypeWriter Effect | Unity Coding (unitycoder.com) […]
hey, i want to make if u press a mouse button the whole text appears, how do i make that happen?
you could probably just have a var for the entire text and then make that show instead when the player presses a button
Thank!
THANKS SO MUCH! I’ve been searching for hours to find this simple solution. Thanks!
Thank you, worked like a charm!
LoL, nice start, but reading the github code suggestion/improvements makes me facepalm a lot.
Any delay can be added inside the coroutine, no need for multiple calls, no need to convert commas or dots, just compare the char dirrectly…
thank you! you’re the only one who made a script that actually works!
oh ohh ohhohoh it works.
How do I take away each character, doing a -= operator does not work.