using UnityEngine;
using System.Collections;
//How to Use
//Add this script to GUITEXT
public class autoType : MonoBehaviour {
//speed
public float letterPause = 0.1f;
//public AudioClip sound;
//declare stanzas
string stanza,stanza2,stanza3,stanza4;
int where;
// Use this for initialization
void Start () {
//put sentences here
stanza = "THIS IS IT";
stanza2 = "new Message";
stanza3 = "hello World";
stanza4 = "next stanza";
}
void Update()
{
//start auto type
SetText(stanza);
//condition to change
if(where == 1)
{
stanza = "";
stanza = stanza2;
}
if(where == 2)
{
stanza = "";
stanza = stanza3;
}
if(where == 3)
{
stanza = "";
stanza = stanza4;
}
}
IEnumerator TypeText () {
foreach (char letter in stanza.ToCharArray()) {
guiText.text += letter;
yield return 0;
yield return new WaitForSeconds (letterPause);
}
//new stanza condition
where++;
Debug.Log (where);
}
void SetText(string text)
{
//StopCoroutine("TypeText");
stanza = text;
guiText.text = "";
StartCoroutine("TypeText");
}
}
As the title says, the text does not change to the next stanza.