- Home /
Debug.Log not printing all values in loop?
While trying to debug some code, I found that not all loop iterations were producing Debug.Log output. I put the loop in a separate class and observed the same behavior. The test class is this:
public class LooperTest : MonoBehaviour {
// Use this for initialization
void Start () {
for (int i=1; i<4; i++) {
for (int j=1; j<6; j++) {
Debug.Log("loop");
Debug.Log(i);
Debug.Log(j);
}
}
}
}
The output I get is:
loop
1
1
2
3
4
5
2
3
My guess is that some statements are being optimized away but I cannot find information on how to turn off loop optimizations in Monodevelop. Alternatively, perhaps not all the output is being flushed? Any advice would be appreciated as this issue has made debugging my code impossible!
Answer by Piflik · Sep 08, 2012 at 06:23 PM
It works for me. Is it possible that you have 'Collapse' active in the console? Disable it and it should be fine.
Okay, my face is red. I am relatively new to the Unity environment and must have inadvertently selected 'Collapse' ins$$anonymous$$d of 'Clear' sometime on the Console. Thanks much, Philipp!
Actually "collapse" is the default, which is kinda bad, because it results in approximately 5,238,491 questions pretty much exactly like this one....
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Why can't I edit C# script although I have monodevelop installed? PLEASE HELP 1 Answer
Automatic caching in Mono? 0 Answers