Skip to content

Instantly share code, notes, and snippets.

@anoadragon453
Created February 15, 2015 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anoadragon453/072f5434cdded2c75473 to your computer and use it in GitHub Desktop.
Save anoadragon453/072f5434cdded2c75473 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class AutoType : MonoBehaviour {
public float letterPause = 0.2f;
public AudioClip sound;
public TextMesh textObject;
string message;
// Use this for initialization
void Start () {
message = textObject.text;
textObject.text = "";
StartCoroutine(TypeText ());
}
IEnumerator TypeText () {
foreach (char letter in message.ToCharArray()) {
textObject.text += letter;
if (sound)
audio.PlayOneShot (sound);
yield return 0;
yield return new WaitForSeconds (letterPause);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment