- Home /
Debug.log in Update without crashing
Hey, I am trying to monitor a variable in Update(). I am using the leap motion so I am listening for different inputs on each frame. I want to know what a variable contains at any given point. How do I debug.log this without having over 999+ log statements in Unity? It doesn't take long before it almost crashes my app. Is there a way to have the debug log every 30 frames or something like that?
the answer provided is correct but the number of log statements should have not effect on how the app runs. (logging slows it down a little bit each frame, but it should be constant, not build up as the number of prints gets larger)...perhaps something else is going on?
if ((Time.frameCount % 30) == 0) {
Debug.Log("Something");
}
But I agree with @perchik, you should not see an increasing slowdown.
Answer by A.Killingbeck · May 01, 2014 at 05:06 PM
currentFrame++;
if(currentFrame >= 30)
{
Debug.Log("INFO");
currentFrame = 0;
}