For loop getting skipped/doesnt work

Here’s the scenario: I’ve got a simple for loop in a coroutine that was working perfectly, and then suddenly stopped evaluating.

Here’s what is looks like, with some debug messages I added in:

	public static IEnumerator CamGoHome () {

                // do stuff

		yield return new WaitForSeconds (flyTime);

		Debug.Log ("hi1");

		for (int i = 20; i <= 0; i--) {
			Debug.Log ("hi2");
			grey.renderer.enabled = !grey.renderer.enabled;
//			yield return new WaitForSeconds (0.5f * i);
		}

		Debug.Log ("hi3");

		// do other stuff
	}

So, this worked before: the renderer of grey blinked, and this worked in multiple tests. I fiddled with the yield return timing in the for loop, saved, and … the for loop suddenly stopped evaluating.

I’ve changed the int used in the for loop, the parameters, cleared the loop out completely. I’ve deleted it and rewritten it. The coroutine always completes (I see the “hi1” and “hi3” messages in the console every time) but it seems to just completely ignore the for loop, or any new for loop of any kind written into the same section of the routine. If I write a for loop up above, it does work, but in that particular section of code it’s just invisible.

Anyone know what would cause this?

for (int i = 20; i <= 0; i–)

this line is the problem, especially the condition.
you are checking if i is less than or equal to 0 at the begining obviously 20<=0 is false so it fails

try

for (int i = 20; i >= 0; i--)   //for 21 times
for (int i = 20; i > 0; i--)   //for 20 times

it is always better to keep the counts increasing rather than decreasing, unless you have the absolute need to do so!

for (int i = 0; i < 20; i++)   //for 20 times