unity iterate through objects with specific script code example
Example 1: unity loop through all objects with tag
var objects = GameObject.FindGameObjectsWithTag("blah");
foreach (var obj in objects)
{
// whatever
}
Example 2: unity3d loop over all gameobjects
object[] obj = GameObject.FindSceneObjectsOfType(typeof (GameObject)); foreach (object o in obj) { GameObject g = (GameObject) o; Debug.Log(g.name); }