Checking if all objects of an array are active at the same time
I've tried to make a script that if all the lights in my scene tagged "Light" are active at the same time, the game proceeds. None of the answers I've found have helped so far. I always end up with it only scanning the active objects, just randomly jumping out of the loop, or stopping when it has found one object that's active. Here is a simple piece of code that should have worked according to other posts
     void Update()
     {
         bool allActive = false;
         GameObject[] allLights = GameObject.FindGameObjectsWithTag("Light");
         if(currenObjective > 0 && currenObjective < 3)
         {
             for (int i = 0; i < allLights.Length; i++)
             {
                 if (allLights[i].activeInHierarchy)
                 {
                     allActive = true;
                     break;
                 }
             }
             if (allActive)
             {
                 currentObjective = 2;
             }
         }
     }
 
               This code just sets the allActive variable to true at the moment one light is turned on.
Your answer
 
             Follow this Question
Related Questions
How can I avoid using switch and for too much? 2 Answers
how to start counting from the last index the script stop on? 2 Answers
Angled Physics.Raycast not returning true (C# / C sharp) 1 Answer
Can someone explain what IEnumerators and for statements are? 1 Answer
Checking if all objects of an array are active at the same time 0 Answers