For loop not working
Hi. I am trying to use two for loops together, however only the first one is working and the second is not. Please help me out.
public GameObject[] day;
private int dayno;
public void Start(){
day= new GameObject[31];
for(int i=0; i<31;i++){
day[i] = GameObject.Find ("DAY" + i);
}
for (int i = 31; i == 0; i--) {
day [i].SetActive (false);
}
}
depends what you trying to achieve for (int i = 30; i > 0; --i)
or for (int i = 30; i == 30; --i)
or for (int i = 30; i >= 0; i--)
Answer by capu087 · Mar 16, 2016 at 07:04 PM
for(int i=31; i>0;--i)
{...
i==0 means that if i = 0, the loop will continue. So probably just a dumb mistake :p
I tried changing it, the second loop still doesnt work.
What do you mean by "the loop doesn't work" ? what is it supposed to do?
Your answer
![](https://koobas.hobune.stream/wayback/20220612072109im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
For loop not looping, Conditional break and return question? 0 Answers
Nested For loop Grouping 0 Answers
Breaking out of the right loop 1 Answer
HOW to USE LOOPS withinh Update??? 0 Answers
FindObjectsOfType not find all objects and code not do anything. 0 Answers