If I have an array of 10 game objects and one of the game objects is deleted, leaving behind a missing game object for the element it was in, how do I detect what element contains a missing game object?
Video tutorial
http://unity3d.com/learn/tutorials/modules/beginner/scripting/if-statements
Read the if and loop section
http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-(long)
If you compare a GameObject with null after it’s destroyed it will return true (even though it’s not really null, it’s just the ‘==’ operator that is overloaded to provide this functionality).
Something like this should do the trick:
GameObject destroyedDude;
foreach(GameObject elem in myArray) {
if(elem == null) {
destroyedDude = elem;
}
}