- Home /
how to find if all objects in array are missing
hi, I have a script who find all my objects in scene if a tag...
and I have a for to make some condition...
`var comidaVerde : GameObject[];
function Awake() { comidaVerde = GameObject.FindGameObjectsWithTag("ComidaVerde"); }
function Update(){ if(fase1){ if(vida >=4){ Application.LoadLevel ("fase1"); vida = 1; }
for(var i = 0; i < comidaVerde.Length; i++){
temComidaVerde = false;
print("entrou");
if ((comidaVerde[i] != null) && (!temComidaVerde))
{
temComidaVerde = true;
}
if(!temComidaVerde){
fase2 = true;
Application.LoadLevel ("fase2");
vida = 1;
fase1 = false;
}
}
}
I want a condition if all objects inside the array are missing , cause i dont want the for continous check if dont have any object in scene to find...
the objects in scene I remove when the character pass through. thanks
Answer by Tiryth · Feb 01, 2012 at 09:13 PM
here has the answer http://answers.unity3d.com/questions/212676/when-all-array-are-nullall-objects-in-array-are-nu.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613063605im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to correctly shorten this script using arrays and iterations 2 Answers
Step through an array and get the GameObjects next to it 0 Answers
Why is this not working? 0 Answers
Change multiple object layers 0 Answers
Array index is out of range 1 Answer