Skip to content

Instantly share code, notes, and snippets.

@miguelSantirso
Created January 27, 2018 13:18
Show Gist options
  • Save miguelSantirso/9647e8712bec3168bdfe9618db502870 to your computer and use it in GitHub Desktop.
Save miguelSantirso/9647e8712bec3168bdfe9618db502870 to your computer and use it in GitHub Desktop.
Naive text reveal
public class TextRevealer : MonoBehaviour {
public Text text;
void Start () {
StartCoroutine(RevealText());
}
IEnumerator RevealText() {
var originalString = text.text;
text.text = "";
var numCharsRevealed = 0;
while (numCharsRevealed < originalString.Length)
{
++numCharsRevealed;
text.text = originalString.Substring(0, numCharsRevealed);
yield return new WaitForSeconds(0.07f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment