Posts

Showing posts from April, 2017

How to create slowly revealed text in a Unity 3d game

Image
I'm sure you have seen games that have text slowly appear on screen. This tutorial will show you how to achieve that look in your game. This will be done using the C# language and using a Coroutine.

Here is what you are going to learn to create:

Depending on how you want to display the text you can do it 2 ways.
1. The first way is to slowly display each letter of the text. This can be achieved using a Coroutine with a set time in-between each letter.
Ex:
IEnumerator TextSlower(float time) { foreach (char ch in theText) { textBox.text += ch; // wait between each letter yield return new WaitForSeconds(time); } StopCoroutine(TextSlower(0.0f)); }
2. The second way is to display each word in the text. This can be achieved using a Coroutine as described above but using String.Split to create an array of words.
Ex:
// create an array of words strArray = theText.Split(' '); IEnumerator TextSlower(float time) { for (int i = 0; i < strArray.L…