Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by vexe · Sep 07, 2013 at 10:25 AM · monodevelopdebugdebuggingvisualstudioide

Editing code in debug mode?

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.

Thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by jbevain · Sep 07, 2013 at 06:53 PM

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.

Comment
Add comment · Show 11 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image vexe · Sep 07, 2013 at 10:03 PM 1
Share

"modify the script and re-attach the debugger afterwards." - wish I could do that. but as I mentioned, my game seems to crash whenever I attempt to edit code. am I missing something?

avatar image vexe · Sep 07, 2013 at 10:19 PM 1
Share

obviously I'm not the only one.

avatar image Benproductions1 · Sep 08, 2013 at 01:53 AM 0
Share

This seems to be an isolated issue. Your Unity is crashing when you do that (and someone else's too), but for the majority of people it seems to work. I think reporting a bug/crash report would be the next step from here

avatar image vexe · Sep 08, 2013 at 02:13 AM 0
Share

It's not that 'Unity is crashing' - it's the game that does. Even in the slightest changes, like changing the string of a debug.log! Idk, gonna have to dig more into it.

avatar image Benproductions1 · Sep 09, 2013 at 07:50 AM 1
Share

@vexe Unity uses serialization in order to "save state" objects. If a variable doesn't need to be preserved between recompiling, then there is no need for it to be serialized. Unity also uses serialization for the inspector. So any prefab is really just a collection of serialized "save state" objects.
Think of making something "recompilation proof" the same as being able to save the entire scene as a prefab and then re-instantiate it after recompiling. Anything that needs to stay between compiles must be serializable.

Show more comments
avatar image
-1

Answer by Will Davis · Sep 07, 2013 at 11:14 AM

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..

Hope that helps :)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Sep 07, 2013 at 11:17 AM 0
Share

This is incorrect. Unity compiles code while in play mode. However note that only serialized data will persist through the compiling

I edit code in Notepad++ and am having no issues with this feature

avatar image Will Davis · Sep 07, 2013 at 11:29 AM 0
Share

Yep I stand corrected. It does seem to run through the code on all updates, never noticed as I've always had to stop/play for the build to show changes but it does not appear to affect the running build.

How are you attaching notepad++ to the debugger.. I didn't know it integrated that much?

avatar image Benproductions1 · Sep 07, 2013 at 12:28 PM 0
Share

You look it up on google, like I did. Theres even a wiki page which tells you how to quite literally "replace" monodevelop with Notepad++

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Monodevelop and Visual Studio 2015 debugger skips frames 0 Answers

Visual Studio 2015 debugger can no longer attach to Unity after installing RC3 1 Answer

Debugger not working in unity3D 4.1.3f 1 Answer

monodevelop vs visual studio? 1 Answer

debugger halt after start(), can only resume in update 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges