Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Source level debugging with Visual Studio?

Discussion in 'Scripting' started by mythicwave, Sep 23, 2011.

  1. mythicwave

    mythicwave

    Joined:
    Jul 13, 2008
    Posts:
    144
    Just wondering whether the same type of source level debugging that's available through MonoDevelop is or could be available through Visual Studio? Are there any technical or other reasons why this isn't feasible?

    Thanks,

    Brian
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Could be made yes, if someone writes a plugin to do so.
    UT does not officially support it for obvious reasons (win only and requires VS Pro to do so as attach to process is not available in the express - while its present in monodevelop on both platforms and without $1000+/yr for msdn)
     
  3. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    There are no technical reasons why you cannot. I have an in-house developed plugin that attaches to the Unity process and does source level debugging but it is not a "best in class" solution at this time.

    I've managed to get VS 2010 partially debugging without resorting to memory hacking but have not had to time revisit the problem due to other priorities. So the answer is "yes, it is possible, but..."

    One more note: You can get it debugging correctly if you run your project in Unity, and then start up VS2010 and have it attach to the appropriate DLL, Irrelevant.DLL IIRC (not got my code editor open at this time). You cannot attach directly to Unity because of the DRM (boo! hiss!) But it means several manual steps (which could be scripted) to get the debugging going. This is less than ideal because what you want to debug, e.g. start-up functions, may well have executed before your debugger is able to attach. You really want VS2010 in at the start.
     
    Last edited: Sep 23, 2011
  4. MrBurns

    MrBurns

    Joined:
    Aug 16, 2011
    Posts:
    378
    @dreamora: To clear things up a little, Visual Studio in its simplest form (PRO without MSDN, which you don't need) only has a onetime free of 800 USD ^^...

    http://www.microsoftstore.com/store...goryID.50804600/categoryID.50804700/list.true

    @Justin: This sounds interesting... After all I wonder how this could work since Unity uses Mono to load the assemblies how could VS possibly hook this up (I mean by default)? I suspect it would only look for loaded NET assemblies?!
     
    Last edited: Sep 24, 2011
  5. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    Go read up on detours.
     
  6. mythicwave

    mythicwave

    Joined:
    Jul 13, 2008
    Posts:
    144
    Very interesting. Thanks for the info. I thought of it because I was looking into this tool for a project originally done with .NET: It supports both MonoDevelop and Visual Studio:

    http://android.xamarin.com/

    -- Brian

     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Actually the code to the mono unity debugger among other things was made public in 2010 when UnityScript became a "public standardized language" or better when UT requested it to be accepted as one and nothing would prevent you from writting a corresponding plugin for VS out of my view, but I might be wrong there though it would really suprise me if the inferior mono (on windows) would exceed the capabilities of VS ;)

    What the xamarin stuff has to do with it though puzzles me cause the unity monodevelop "attach to process" works against win, osx, webplayer, android and iOS too


    And thanks for the link to the one MS Store. Unhappily we all know that the store exists in only very few countries, but perhaps it by now is able to accept customers from other countries.
     
    Last edited: Sep 24, 2011
  8. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    I did not know that. I shall have to investigate further and find out if we can finally chuck our code injection system.
     
  9. MrBurns

    MrBurns

    Joined:
    Aug 16, 2011
    Posts:
    378
    @Justin: What should I read on detours ^^? I wrote the successor of Detours some years ago ^^... That's not what I want to know. But ok, so it seems like no sane way either if you hook into it.