Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

VS Code Unity Debugger Extension Preview

Discussion in 'Scripting' started by lukaszunity, Nov 24, 2015.

  1. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89
    Tried following the extension plugin here, as soon as hit the green debug triangle I just get this error:

    spawn mono ENOENT

    It doesn't attach to the Unity process at all
     
  2. laotaoloris

    laotaoloris

    Joined:
    Feb 23, 2016
    Posts:
    1
    same problem, can I run debugger perfectly without updating Unity version? @lukaszunity
     
  3. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Do you have the Mono installed? http://www.mono-project.com/download/


    I need more details on the issue. I don't think anything changed with regards to debugging in Unity 5.3.1p1.
     
  4. IndieForger

    IndieForger

    Joined:
    Dec 31, 2012
    Posts:
    92
    Is that bug there again? Every time I click play btn I got annoying popup "Checking for updates..." that hangs there for 3 - 5 min. It really kills me and makes the VS Code practically unusable. Is there way to switch it off somehow?
     
  5. RichCodes

    RichCodes

    Joined:
    Apr 3, 2013
    Posts:
    142
    @IndieForger Latest version on Github does not have that bug. Also, make sure you have Automatic Updates turned off in the preferences.
     
  6. CDMcGwire

    CDMcGwire

    Joined:
    Aug 30, 2014
    Posts:
    133
    That was surprisingly easy to setup. This will be great for when I'm on my laptop.
     
  7. K0jo

    K0jo

    Joined:
    Aug 23, 2013
    Posts:
    8
    Hi. This plugin is pretty cool. I'm trying to get it running on Linux and have gotten pretty far so far. Now I'm just trying to connect the debugger. I've updated my version of mono to what I believe is the latest (4.22) and installed the unity debugger extension.

    When I press the debug button next to the setting "Unity Editor" I get the following error. "Multiple targets with the name 'Unity Editor' running. Unable to connect." Anyone run into this on Linux or any other platform?
     
  8. K0jo

    K0jo

    Joined:
    Aug 23, 2013
    Posts:
    8
    Figured this out. The problem is that the UI for any recent version of Ubuntu is also called "Unity". The code that looks for a unity process to attach to finds several Ubuntu UI processes (ie, unity-settings-daemon, unity-panel-service, unity-scope-home, etc.). I actually had to rebuild the debugger extension from source (which was a pain for a few reasons) and update the check that attaches unity processes to exclude any process name with a hyphen. It's a kludge but it's worked for me for now.

    @lukaszunity I think you guys are definitely going to need to handle this case since most Linux users run Ubuntu and I think this will be a very common problem.
     
  9. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Just an update. K0jo has opened an issue to GitHub for this issue and it will be fixed soon.
     
  10. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Version 1.0.2 is now available.

    Changes:
    • Improved support for expressions added with "Add Watch"
    • Fixed issue with being unable to attach to Unity editor on Ubuntu, when using Unity graphical shell.
    • Attaching to the Unity Editor is faster.
    • Update debugger protocol to latest version.
     
    operator23 likes this.
  11. Amonsat

    Amonsat

    Joined:
    Mar 26, 2015
    Posts:
    8
    How you get highlighted Unity syntax ? In my case "void, update, fixedupdate, float" all is white color.
     
  12. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    C# syntax highlighting is provided by Microsoft, you can report issues to them here: https://github.com/Microsoft/vscode/issues
     
  13. JamieFristrom

    JamieFristrom

    Joined:
    Nov 2, 2012
    Posts:
    20
    FWIW, I couldn't step through code with the debugger until I completely removed dotbunny's thing.
     
  14. scionkiller

    scionkiller

    Joined:
    Apr 27, 2014
    Posts:
    5
    Can anyone help me? I have the extension installed as well as DotBunny's VSCode integrator. Even though I have the VSCode integration set to use the Unity Debugger, whenever I connect, I get this exact output:

    UnityDebug: Initializing
    UnityDebug: Searching for Unity process 'Unity Editor'
    UnityDebug: Attached to Unity process 'Unity Editor (Unity)' (17315)
    UnityDebug: Disconnected

    The third line lasts for a few seconds, and the bottom of the VSCode window bar is orange, and then all of a sudden it disconnects and shows a blue bar again.

    I could uninstall the dotbunny thing as JamieFristrom has suggested, but then I lose the convenient integration of VSCode, which is not handled natively in Unity yet? Does anyone have a fix for this?
     
  15. scionkiller

    scionkiller

    Joined:
    Apr 27, 2014
    Posts:
    5
    Removing dotbunny did not help, I got the exact same behaviour.
     
  16. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    It looks like the dotBunny plug-in disables editor attaching in some cases. You can enable this manually in Preferences -> External Tools -> Editor Attaching. You can also work around this issue in the dotBunny plugin by commenting some code, more details here: https://github.com/Unity-Technologies/vscode-unity-debug/issues/6#issuecomment-200609066

    Notifying @Reapazor
     
  17. smallbit

    smallbit

    Joined:
    Oct 3, 2013
    Posts:
    60
    Keeps disconnecting even after I did the fix. Is it supposed to work on Mac ?
     
  18. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Yes, it should work on Mac. Is Editor Attaching in Preferences -> External Tools enabled?
     
  19. smallbit

    smallbit

    Joined:
    Oct 3, 2013
    Posts:
    60
    Hi,
    Yes I have it selected,

    Code Output:

    UnityDebug: Initializing
    UnityDebug: Searching for Unity process 'Unity Editor'
    UnityDebug: Attached to Unity process 'Unity Editor (Unity)' (475)
    UnityDebug: Disconnected

    My launch.json

    {
    "version": "0.2.0",
    "configurations": [
    {
    "name": "Unity Editor",
    "type": "unity",
    "request": "launch"
    },
    {
    "name": "Windows Player",
    "type": "unity",
    "request": "launch"
    },
    {
    "name": "OSX Player",
    "type": "unity",
    "request": "launch"
    },
    {
    "name": "Linux Player",
    "type": "unity",
    "request": "launch"
    },
    {
    "name": "iOS Player",
    "type": "unity",
    "request": "launch"
    },
    {
    "name": "Android Player",
    "type": "unity",
    "request": "launch"

    }
    ]
    }

    I had problem with that json previously when still had monoDebug installed so I needed to disable "Always write Launch file"

    Should I have enabled "Use Unity Debugger" in Vs options in Unity? When I do so I tells me that extension is not installed, even after I click to do so, maybe the problem is here.

    Dzieki !
     
  20. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Do you have the latest version of the dotBunny plugin? Some issues regarding debugger attaching were recently fixed. I would suggest trying to uninstall the dotBunny plugin and trying again while making sure editor attaching is enabled. You could also try to debug with MonoDevelop to see if this is a general debugging issue or specific to VS Code.
     
  21. smallbit

    smallbit

    Joined:
    Oct 3, 2013
    Posts:
    60
    Yup, Update did the trick thank you very much.
     
  22. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    Hi,

    I just got the VS Code Unity Debug plugin. My setup doesn't use dotBunny's plugin. I just followed the steps at: https://marketplace.visualstudio.com/items?itemName=Unity.unity-debug . I am using Unity 5.3.4 on OS X. I've put a break point in my code, hit play in both VS Code and the Editor and nothing happens. VSC connects to Unity just fine based on the messages I get in the debug console, but the breakpoint doesn't hit. Also I don't see any variable in the variables window.

    I'm using a basic script just to set the value of a variable, nothing fancy. Editor attaching is enabled. Is there something I missed? I'd really like to be able to debug with VS Code as it would save me a lot of time. Thanks
     
    Last edited: Apr 29, 2016
  23. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Does the breakpoint hit when using MonoDevelop to debug?
     
  24. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    I've tried it and I can confirm that when the breakpoint hits, the focus goes to monodevelop. I tried watching variables and it also works in monodevelop. This was all done with the same project that isn't working with VS Code.
     
    Last edited: Apr 29, 2016
  25. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Which version of the Mono framework do you have installed? There have been some reported issues with Homebrew Mono being installed alongside the installer version from http://www.mono-project.com/download/.

    You could also try to see if the log file in ~/.vscode/extensions/Unity.unity-debug-1.0.3/bin/UnityDebug-log.txt contains any details on why the breakpoints fail to hit.
     
  26. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    Hi,

    In the log, there's only

    Found Unity process: Unity Editor (Unity) (4058)

    As for Mono, I also have Xamarin Studio 5.10.3 installed on my computer and I update it regularly along with Mono directly from the "Check for updates" option in the menu.

    When running "mono --version", I get:

    Mono JIT compiler version 4.2.3 (explicit/832de4b Thu Mar 3 19:24:57 EST 2016)
    Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS: normal
    SIGSEGV: altstack
    Notification: kqueue
    Architecture: x86
    Disabled: none
    Misc: softdebug
    LLVM: yes(3.6.0svn-mono-(detached/a173357)
    GC: sgen

    I will try to debug on my other mac computer and see if it does the same thing.
     
  27. VertexSoup

    VertexSoup

    Joined:
    Nov 25, 2014
    Posts:
    44
    Hello, I'm getting this error and I'm unable to find solution for this...
    "Error starting OmniSharp"

    [INFO] Starting OmniSharp at 'c:\My\Project\Path.sln'...
    [ERROR] Error: spawn cmd ENOENT

    I tryed to uninstall and reinstall latest version, got latest .net package, updated mono, nothing helped so far... :/ I'm disappointed, might go back to slightly buggy but working Consulo... I hope you are working on Rider support as well!
    Am I alone who experience this? Would be glad for any insight why this is happening.
    HW:MBPro (model A1398) SW:Win7
     
  28. MatiasJP

    MatiasJP

    Joined:
    Nov 4, 2013
    Posts:
    16
    Hi guys I'm currently trying to get VSCode work propertly with unity but when I go to the debug section an try to watch a class variable ( "_i" in the example ) is not giving me anything but works with the local variable ( "test" in the example).

    Here is the example:

    http://i.imgur.com/vWVF78n.jpg?1

    Thanks in advance for your help!

    EDIT: Okay, I answer myself after reading the page 2, I needed to include "this."
     
    Last edited: May 22, 2016
  29. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    Hi folks, I've just started using this extension and can't seem to get the debugger to break on exceptions. Is this supported currently? If so how do I enable it? If not, are there plans to support it?
     
  30. yosske

    yosske

    Joined:
    Jun 9, 2016
    Posts:
    3
    Hey, installing mono fixed the problem for me, thanks!
     
  31. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    Hi I've been using VSCode successfully for a few months, thanks for supporting this great editor. There are some things about the debugger that really make it difficult to use with Unity.

    The biggest thing is how the Variables panel shows the fully-qualified typename in front of the variable names. This makes it cumbersome to find what you need in the view. Is there a hidden setting to hide the types?

    Second problem is you can't examine or watch "this" members and properties without adding the "this." prefix on them. This also means you can't hover over member variables in the source code to see their values.
     
  32. greay

    greay

    Joined:
    Mar 23, 2011
    Posts:
    88
    Is it possible to break on exceptions?
     
  33. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    This is currently not supported. I've added it as feature request to our backlog.
     
  34. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    This is how VS Code works, it is very hard for the debugger extension to do anything about it. More details: https://github.com/Unity-Technologies/vscode-unity-debug/issues/15
     
  35. danjakes

    danjakes

    Joined:
    Jun 5, 2015
    Posts:
    8
    Hi, I'm unable to view the contents of lists and dictionaries on breakpoint. Is there a way to do that?
     
  36. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Are the types generic? Our current Mono runtime does not support inspection of generic types in the debugger, this will be fixed once the Mono runtime is upgraded.
     
  37. danjakes

    danjakes

    Joined:
    Jun 5, 2015
    Posts:
    8
    I have something like this..

    Dictionary<string, Dictionary<string, CustomObject>>

    I also have a list of the above dictionary..
     
  38. seansyou

    seansyou

    Joined:
    Sep 19, 2014
    Posts:
    2
    Last edited: Dec 19, 2016
  39. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    I'm able to get the debugger to stop on breakpoints, but I'm not able to see any variable information once I hit a breakpoint. If I add a in scope variable to the watch list I get "Evaluate Request Failed"

    Weeks ago I had it working so I could see variable values, now I can't figure it out, have tried redoing the setup process several times. Any ideas?!
     
    ROBYER1 likes this.
  40. seansyou

    seansyou

    Joined:
    Sep 19, 2014
    Posts:
    2
    @lukaszunity
    Hi, I recently start to use vscode to replace monodevelopment, I met some problems want to ask for:
    1. I couldn't see the information of class variable unless I add it into watch list.
    2. "Time.time" always show the infomation of "Evaluate Request Failed".

    Could any way to solve these things?
     
  41. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Yeah, somewhat kinda painful to debug in VSCode. The good news is that the integration and debugging process is just works right now, through...

    1. I can't see value of variables directly, unless it is an argument variable (But STILL can do that in 'variables' list)
    2. The watch list can't ever used to see static variables (like Time.time) (But 'variables' list CAN do that, if it listed)
    3. I can't set breakpoints for exception.

    The integration is closer to perfect, and I hope those irritating bugs can be thrown by now, because VSCode is my primary IDE when work in Unity.
     
  42. aleksander_rovio

    aleksander_rovio

    Joined:
    Jul 27, 2016
    Posts:
    1
    Looks like it works only with the main thread. If code hits breakpoint in none main thread, VS code unable to show any information - call stack, variables, watches are epmty in this case.
     
  43. RedBjorny

    RedBjorny

    Joined:
    Nov 29, 2016
    Posts:
    19
    I have some issue with debugging in VS Code on Mac:

    'Step into' breaks debugging at the line where there are properties or methods of Unity classes.
    For example, can't debug code like this:

    Code (CSharp):
    1. public class VSCodeDebugging : MonoBehaviour {
    2.  
    3.     // Use this for initialization
    4.     void Start ()
    5.     {
    6.         Func(transform.right.x);
    7.  
    8.     }
    9.     void Func(float x)
    10.     {
    11.         Debug.Log(x);
    12.     }
    13.  
    14. }
    All debug options (Step Over, Step Into) become greyed when I click 'Step Into' at line 6.
    But the same code can be perfectly debugged when I first cache function argument.
    Code (CSharp):
    1. public class VSCodeDebugging : MonoBehaviour {
    2.  
    3.     // Use this for initialization
    4.     void Start ()
    5.     {
    6.         float transformX = transform.right.x;
    7.         Func(transformX);
    8.  
    9.     }
    10.     void Func(float x)
    11.     {
    12.         Debug.Log(x);
    13.     }
    14.  
    15. }
    Nevertheless, if I click occasionaly 'Step Into' at line 6 in new code, then debugging stops.
     
    Last edited: Mar 11, 2017
  44. Xepherys

    Xepherys

    Joined:
    Sep 9, 2012
    Posts:
    204
    I've also just started having issues with debugging Unity code. Anytime I hit something built in, like a coroutine, I get a message like this:

    Unable to open 'Coroutines.cs': File not found (/Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs).

    This only started happening within the past several days, and I only noticed it because one of my coroutines stopped firing, and when I tried to debug it, I get this when it tries to step into the coroutine.
     
  45. routitsm

    routitsm

    Joined:
    May 1, 2016
    Posts:
    2
  46. ahmed_unity531

    ahmed_unity531

    Joined:
    Dec 1, 2017
    Posts:
    1
    I'm trying to get the android debugger connecting but not having much luck, when I hit F5 to connect to the android player I get the following:

    The Android device is connected and I can see adb logging, just that the debugger won't connect.
     
  47. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    I think UT said the VS Code debugger can only connect to the Editor, but that was long time ago and I may have missed if they maybe changed that since then.
     
  48. Auriga

    Auriga

    Joined:
    Aug 17, 2013
    Posts:
    5
    I believe I'm having the same experience as RazieIn64. Unity is not stopping on breakpoints of a simple project. I am not using the dotBunny plugin.

    The Debug Console reports that it is "Attached to Unity process 'Unity Editor (Unity)'"
    The Call stack is populated with three Threads but there is no information in Watch or Variables.
    In Unity preferences, External Tools, I have set Visual Studio Code and the Editor Attaching box is checked.
    MonoDevelop and Visual Studio Community 2015 both successfully stop on breakpoints.

    I have tried this on two different computers with similar settings (except the 2nd computer is running Visual Studio Community 2017) and have the same experience.

    I'm running Windows 10, Unity 2017.3.1f1, VSCode 1.20.1, Unity Debugger 1.3.0.
     
  49. frankadoriv

    frankadoriv

    Joined:
    Jul 19, 2017
    Posts:
    14
    So, guys there is not more advance about this issue? (Breaking points and variables inspection and of course android debug)
     
  50. Lyje

    Lyje

    Joined:
    Mar 24, 2013
    Posts:
    169
    I'm also still unable to inspect most variables in the debugger. This is a pretty critical issue - not much point having a debugger if it can't tell you what's going on.