- Home /
How do you implement a script like this one...
Hi guys,
I've been wanting to implement a script like AutoType.cs found here:
http://wiki.unity3d.com/index.php/AutoType
However, I am too noob to understand how you would use something like this though.
Could anyone explain the process of what scripts you would attach where and what values get passed to who to get this to type out in a GUI Rect?
Thanks in advance!
For your convenience, here is AutoType.cs:
using UnityEngine;
using System.Collections;
public class AutoType : MonoBehaviour {
public float letterPause = 0.2f;
public AudioClip sound;
string message;
// Use this for initialization
void Start () {
message = guiText.text;
guiText.text = "";
StartCoroutine(TypeText ());
}
IEnumerator TypeText () {
foreach (char letter in message.ToCharArray()) {
guiText.text += letter;
if (sound)
audio.PlayOneShot (sound);
yield return 0;
yield return new WaitForSeconds (letterPause);
}
}
}
Answer by Orion_Reed · Mar 21, 2013 at 08:03 PM
Attach it to an object with a GUI Text on it, then choose how fast it should type and the sound for each time a letter is typed. and there you go! if that doesn't work then say so, but it should.
Regards, Orion.
Thanks for the help. That got me a little bit further. When I did what you say, it only shows the first letter of the string on my screen and doesn't play the sound.