Created
January 27, 2018 13:18
-
-
Save miguelSantirso/9647e8712bec3168bdfe9618db502870 to your computer and use it in GitHub Desktop.
Naive text reveal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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