Debugger
Manual     Reference     Scripting   
Unity Manual > Advanced > Debugging > Debugger

Debugger

The Unity Debugger lets you inspect your code at runtime. For example, it can help you determine when a function is called and with which values. Furthermore, it allows you to look at the value of scripts' variables at a given time while running your game. You can locate bugs or logic problems in your scripts by executing them step by step.

Unity uses the MonoDevelop IDE to debug the scripts in your game. You can debug all the languages supported by the engine (JavaScript, C#, and Boo).

Note that the debugger has to load all your code and all symbols, so bear in mind that this can have a small impact on the performance of your game during execution. Typically, this overhead is not large enough to affect the game framerate.


MonoDevelop window debugging a script in unity.


Debugging in Unity.

On Windows, users must choose to install MonoDevelop as part of the Unity installation (selected by default).










  • When you enter play mode, your script code will execute in the debugger.
  • When a breakpoint occurs, script execution will stop, and you will be able to use MonoDevelop to step over, into, and out of your script methods, inspect your variables, examine the call stack, etc.
    • Note: When you're done debugging a toplevel method (e.g. Update()), or you just want to jump to the next breakpoint, you will experience better debugger performance by using the Continue command instead of stepping out or over the end of your function.



Hints.



iOS remote debugging instructions

In addition to the instructions described above, Unity iOS applications require some additional steps for successful debugging:

  1. Attach your iDevice to your WiFi network (the same requirement as for remote profiling).
  2. Hit build & run in the Unity editor.
  3. When the application builds, installs & launches via Xcode, click Stop in Xcode.
  4. Manually find & launch your application on your iDevice. (Note: if the application is launched via Xcode you won't be able to resume after reaching a breakpoint).
  5. When the app is running on the device, switch to MonoDevelop and click on the attach icon in the debugging toolbar. Select your device from the available instances list (if there are several instances shown, then select the bottom one).


Page last updated: 2011-05-23