For instead of foreach

Heard that using foreach is not a good idea in update and that one should use a regular for.

How would you do that for the child transforms?

bool AllMembersDead()
{
    for (int i = 0; i < transform.childCount; i++)
    {
        if(transform.GetChild(i).childCount > 0) return false;
    }
    return true;
}

OK, found it (with Unity 2017.1)

Privacy & Terms