why is this not working here below.?
error in the console is: GameObject is not a member String.
var monkey1 : GUITexture;
var monkey2 : GUITexture;
var monkey3 : GUITexture;
var monkey4 : GUITexture;
functions ShowIt(){
for(var k:int = 1; k<4; i++){
var oops = ("monkey" + k);
oops.gameObject.active = true;
}
The variable oops is of type string and not of type GUITexture. Its values will be “monkey1”, “monkey2” and so on. And as the error message says: GameObject is not a member of type string.
If you want to iterate (loop) all your GUITextures you should put them in an array. But if you only have 4 you could just access them one by one.
monkey1.gameObject.active = true;
monkey2.gameObject.active = true;
monkey3.gameObject.active = true;
monkey4.gameObject.active = true;
//ohm
Then you can use an array (a collection of variables, for instance 50 monkeys). I’m not sure about the javascript syntax but something like this:
var monkeys : GUITexture[];
functions ShowIt()
{
for(var k:int = 0; k<monkeys.length; k++)
{
if (monkeys[k] != null monkeys[k].gameObject != null)
{
monkeys[k].gameObject.active = true;
}
}
}
aha, now i have learned a lot.
An array of guitexture instead of just an array! thanks
\now the errror that is expect : instead of = in the last line of coding
i got it working, thanks.
I had a typo