How to make checkbox checked when all enemy is dead please help

How to make checkbox checked when all enemy is dead please help

The easiest way would be to have all types of enemies in your game derived from the same class, let’s call it ‘Enemy’. Then you’d make sure Enemy has some kind of boolean declared, let’s call it ‘isDead’. Now all you’d need to do is use one of Unity’s built in functions for finding Object’s, ‘FindObjectsOfTypeAll()’.

You’d just need to plug this loop into wherever you’d want the check to occur to see if all enemies are dead.

foreach (Enemy enemy in Resources.FindObjectsOfTypeAll<Enemy>())
{
    if (enemy.isDead == true)
        isAllDead = true; // public boolean to represent checked checkbox in inspector
    else
        isAllDead = false; // public boolean to represent checked checkbox in inspector
}

And of course make sure to declare isAllDead as a public boolean somewhere for it to show up in inspector as a checkbox.