How can I attach a debugger to the code running on the editor or to the builded client

Is there a way to attach a debugger to the unity3d process?

I could not find a way do this using Visual studio 2008. Is it possible to do that using MonoDevelop?

With Unity 3.2 this feature now exists.

You have to debug using the MonoDevelop that ships with Unity 3.2.

When you have the project open in MD, click Run > Attach to Process. Then choose the Unity editor process or your running built debug exe. If you attach to the editor, you can start and stop the game editor at any time using the "play" button or Ctrl+P.

Currently the following options are available to find problems with your project:

  • Debug "visually" by pausing the game, and inspecting values of scripts in the inspector
  • Using Debug.Log() messages, to see where things are going wrong
  • You can run your C# code in the VisualStudio debugger, but only those parts that do not interact with the Unity API.

Hopefully this will not be true for a very long time.

You can also debug Unity projects using Visual Studio. The UnityVS Visual Studio add-on was developed by SyntaxTree, who were recently acquired by Microsoft.

More information here.