- Home /
Script stops working when switching to Android
i have a script that types a GUI text out with sound like a computer and it works perfectly on PC but when i try to distribute it to an .apk for android it gives me
Assets/Scripts/TYPE TEXT.js(13,33): BCE0019: 'ToCharArray' is not a member of 'Object'.
i know it might be a simple solution but i cant seem to fix it.... can someone please help me??
here is the script...
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);
}
}
Answer by OperationDogBird · Sep 23, 2013 at 07:23 PM
You need to specify the type of the variable 'word'. Since its a string i would simple declare the type as String or use var word = ""; It is a very bad habit to not define the type of your variables, even something straight-forward like this.
As the error states, type object or Object do not have a method ToCharArray(). String however does, explicitly stating the variable as string will solve the issue.
Your answer
Follow this Question
Related Questions
BCE0019: 'position' is not a member of 'Object' 4 Answers
Change 3D Object by pressing Gui Button 1 Answer
Ammo Script gives "object reference not set to an instance of an object" 1 Answer
Having script accessing issues 2 Answers
Script problems 1 Answer