(Maybe my English isn´t perfect)
Hi, I want to use this script, but with the JS version I get an error and the CS version does nothing.
The error: “ToCharArray” is not a member of “Object”
var letterPause = 0.2;
var sound : AudioClip;
private var word;
function Start () {
word = guiText.text;
guiText.text = "";
TypeText ();
}
function TypeText () {
for (var letter in word.ToCharArray()) {
guiText.text += letter;
if (sound)
audio.PlayOneShot (sound);
yield WaitForSeconds (letterPause);
}
}
And the CS version does nothing, the text will be displayed normally (Not letter by letter)
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);
}
}
}
Thanks in advance…
take a look at [this][1] which has helped others in the past. [1]: http://answers.unity3d.com/questions/735306/auto-type-text-does-not-change-to-the-next-sentenc.html
– gjfIf you would say what error exactly you get maybe it would be easier for us to help.
– ZodiarcSorry, I forgot to write what line the error is. Im not on my Computer at the momen, I'll post it later
– N00MKRAD