I just watched this video. I don’t know how, but he seems to be able to edit the game’s code while he’s in debug mode! - Is this something standard when you code in Monodevelop?
I never use Monodevelop because it’s very crashy. I use VS and have UnityVS the debugging plugin. But the problem is I can’t edit code, it won’t allow me, unless there’s an option/setting that I’m missing to enable edit, is there?
Although I’m not quite sure that the guy in the video was using Unity, but in anyway, in general, can I edit my code when debugging in VS and/or Monodev?
From what I know, if you edit the code while the game is running it will crash.
Visual Studio, with UnityVS, prevents the edition of C# scripts while debugging.
As it has been noted, Unity itself is definitely able to handle serializing the game, recompiling and deserializing the game. The issue is that if you’re in the middle of a debugging session it can be really tricky.
Let say you have:
void Update()
{
var s = "foo";
Debug.Log(s);
}
Then you put a breakpoint on the var s = "foo"; line.
You run your game, the debugger breaks, and shows the current line.
If you modify the script at that point in time, and add new lines between the declaration and the Debug.Log call, you’ll have the feeling that you’re modifying the current running method. And that if you step you’ll step into the new code. Sort of like you can do it in Edit & Continue with .net. Except it’s not the case.
As Unity doesn’t support Edit & Continue as Visual Studio understands it, it prevents the edition of scripts while debugging. Which is not that big of an issue as you can very simply detach, modify the script and re-attach the debugger afterwards.
With the exception of Shader changes, unity does not recompile code whilst in play mode I believe, you can edit and save code however, but it will not recompile in unity until you stop playmode.
Although I do sometimes get issues debugging and making changes more so when the debugger has caught a breakpoint etc.
Also I seem to remember in the mono settings we had a reason to specifically set it to not build in mono (tools>options> scroll down to Unity >debugger…