I need my script to continue after i have set the first, help
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
// bla bla bla from line 33
foreach (var b in buttonlist) {
Inactivebuttonlist.Add (b);
buttonlist.Remove (b);
b.gameObject.SetActive (false);
**// My function stop here, but there is still more to be done**
}
PlanetAdminHolder.SetActive (false);
// bla bla bla
Comment
Best Answer
Answer by kornstar83 · Jun 07, 2017 at 11:19 PM
when you are removing the item from the list it is changing the length (count) of the list, maybe it has something to do with that.
try something like:
foreach (var b in buttonlist) {
Inactivebuttonlist.Add (b);
b.gameObject.SetActive (false);
}
buttonlist.clear(); //empty the list after the foreach has run its course
PlanetAdminHolder.SetActive (false);
// bla bla bla
Your answer

Follow this Question
Related Questions
Pass a reference to a button that opened the menu this script is on 0 Answers
How to get component value without using GetComponent() and Update()/FixedUpdate()? 1 Answer
Syncing SetActive over network 0 Answers
Other way to write a code 0 Answers
Canvas not de-activated when played in APK (works in unity editor) 0 Answers