How do I check if all gameObjects in a list meet a certain condition in Unity? I have 9 colliders with the same script. They all have a list, which changes through I tried this code, but it returns weird results.
void Update()
{
for (int i = 0; i < ChildTiles.Count; i++)
{
if (ChildTiles [i].GetComponent<SpriteRenderer> ().color == Green)
{
_greenComplete = true;
}
else
{
_greenComplete = false;
}
//Debug.Log (gameObject + "ChildTiles[i]" + ChildTiles [i]);
}
Debug.Log (gameObject + "Green Complete " + _greenComplete);
}
The weird thing is that the top-right collider returns True, with two gameObjects with a green color and the bottom-right collider returns false, with two gameObjects with a green color.
This it the inspector of the top-right collider during this result:
This is the inspector of the bottom-right collider during this result:
How can I solve this?


