Is there a

Hi, I'm just starting out with Unity and I'm having trouble debugging a script of mine. Is there a keyboard command (like Ctrl-C) that breaks or aborts the running of a script? Or even better, a debug mode that I just can't find? When I run this thing currently unity totally freezes (though Windows doesn't report it as not responding, it isn't), and I have to force quit it to get back to work.

Thanks, Sam

Because the front-end of the Unity Editor is also running on Mono, a script in an infinite loop effectively means the editor is in an infinite loop. The only way to stop it is to force quit from your operating system.

Unity 3, out soon, will have a source-level debugger that you can use for debugging scripts.

Until then, all you can do is things like:

  • Sprinkle Debug.Log calls throughout your code to see where the error occurred.
  • Keeping in mind your recent changes (it worked, you wrote some code, now it doesn't work) you probably have a pretty good idea where to start looking.
  • Deactivate the script you think is the problem, verify that the problem is gone, then add half of it back. Repeat until you've figured out which lines are the problem.