Ok, firstly i would like to tell you i’m struggling with this array command in javascript. I’m trying to create a script to pause the game, and once the game is paused, the script should display components in a few gameobjects which is held in an array. Look at my code, it says an error saying the variable ‘i’ already exists, but when i try to change it to something like ‘j’ nothing happens.
var obj : GameObject;
var displayPauseObjects : boolean = false;
function Awake(){
obj = GameObject.FindGameObjectsWithTag("PauseObjects");
}
function Update(){
if(Input.GetButtonDown("Pause") && displayPauseObjects == false)
{
for(var i = 0; i < obj.length; i++){
obj*.GetComponent(GUITexture).enabled = true;*
-
}*
displayPauseObjects = true;
-
}*
//The First Part Works fine! When i press the pause key the game object’s GUI Texture
//component gets displayed. But again to hide the components the code doesnt work. -
if(Input.GetButtonDown(“Pause”) && displayPauseObjects == true)*
-
{*
-
for(i = 0; i < obj.length; i++){*
_ obj*.GetComponent(GUITexture).enabled = false;_
_ }_
_ displayPauseObjects = false;_
_ }*_
}