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

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Last edited: Jan 21, 2016
    pea, drawcode, CodeFighter and 16 others like this.
  2. dousi96

    dousi96

    Joined:
    Jul 28, 2014
    Posts:
    23
    Thanks! Very usefull!!
     
    charmandermon likes this.
  3. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Sounds great - How good is VS Code compare to MonoDevelop ? I'm developing on a Macbook Pro and I'm not that much a fan of MonoDevelop.

    Thanks.
     
  4. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    I think it is up to the individual developer decide how good any code editor is and which one they like best.

    The VS Code website has some information on how to get started with VS Code and Unity: https://code.visualstudio.com/Docs/runtimes/unity
     
    charmandermon likes this.
  5. Aram-Azhari

    Aram-Azhari

    Joined:
    Nov 18, 2009
    Posts:
    142
    Thank you Lukas.

    I seem to be having this problem when pressing the green button. Any ideas?

     
  6. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Which version of Unity and the Mono framework are you using? Does this also happen to you on a new project with a single script?

    I will add more logging in a future to be able to track down issues like this more easily.
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I am using the beta MonoDevelop (5.9.6), but also have the beta VS Code installed. Just wondering which is preferred?

    for now, it seems that VS Code is still not mature as MD. Does anyone have any good arguments for choosing one over the other ?
     
  8. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    cant speak to how stable VS Code is, since im a VS pro user, but i think it will come down to preference. VS Code is growing very fast, and has all the basics down.

    Though i have noticed the syntax highligting of VS Code dost seem quite right yet. It dosnt seem t highlight type names in code like VS proper or MonoDev would, which really harms readability. The weird part is that OmniSharp obviously know what the types are since it will give a next tooltip for Typename when hovered.
     
    Last edited: Nov 24, 2015
    Xepherys likes this.
  9. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    I was quite impressed with VS code and it does have some really neat features, like listing number of references next to attributes. The highlighting is as mentioned not that good by some reason, the only deal breaker as I see to use it in daily development is that it lacks tabs. The font rendering on Mac is also a little iffy compared to old Monodevelop or Sublime text.
     
  10. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    VS Code is already really good. It's maybe missing a few things here and there, but the addition of extensions in the latest version and the fact that it's open source will probably make it evolve even faster.

    I believe the lack of tabs is by design. It's a different approach to file editing. Rather than having a few visible tabs on top, you have a list of all files you're currently editing on the left, under "working files". It's a much easier way to browse, and names are more visible. But it's also a different paradigm than most editors use, so I can understand why it doesn't feel natural to some people... but, once you get used to it, it's a much better approach to editing projects especially when you take source control into account.

    This is pretty symbolic of what VSC is to me. It's not trying to be a clone of Mono Develop, or Visual Studio. It's only doping the basics so far, but doing it better because it can start from scratch and from lessons learned in other lightweight editors like sublime. There's no "project files" either - you open the folder and that's your project. That's another example of the editor's anti-monolithic approach.
     
  11. almo

    almo

    Joined:
    Jul 14, 2010
    Posts:
    83
    If it has a "trim trailing whitespace" option, I'm sold.
     
  12. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    ya lacking of tabs dosnt bother me, since it is often faster to just control+P and mash a few letters in the class name you want.

    Also great that it has extensions, would be dam nice if it starts getting resharper like features as extensions, and some good vim bindings
     
  13. Cybexx

    Cybexx

    Joined:
    Dec 4, 2008
    Posts:
    23
    I've been using this to do my work this morning and so far it is working mostly great. You might want to add some additional steps to the Install Instructions to tell people how to set VC Code as their external script editor and set
    Code (CSharp):
    1. "window.openInNewWindow": false
    in the settings file to make this a full workflow replacement of Monodevelop, since some people may have never user alternative script editors.

    VS Code doesn't seem to understand namespaces very well though. In this example it claims the EggZagStoreData class doesn't exist, which is defined under the Elink.Eggzag.Store namespace. EggZagStoreData extends from ScriptableObject which extends from Object so it should have a definition for name but you'll notice that this.name is also highlighted.

    VSCodeNamespaceIssue.jpg
     
  14. blahblahkar

    blahblahkar

    Joined:
    Nov 13, 2015
    Posts:
    5
    I agree with Cybexx, namespace aren't working all that great for now. Same with hovering on static member variables, but that could be a consequence of the namespace pb (static function nested in class nested in namespace). Same when adding these variables into the watch window -> not evaluated.

    Also, I wish I had some sort of project and see/browse all the files (maybe I missed something), something like Alt-Shift-O (for those familiar with Visual Assist). A similar search for symbols would also be VERY nice.

    Overall, this is promising. VS Code wasn't available ~6 months ago and it's getting a lot of love. A few more strong iterations and we'll be able to ditch Mono (no tears here!) and won't have to bother with Visual Studio running in a VM.
     
  15. owenbirdsall

    owenbirdsall

    Joined:
    Jul 7, 2015
    Posts:
    1
    I've been using VSCode to write C# scripts for my Unity project on OSX, but it seems to fail at the most basic tasks.

    The format code option hasn't worked for me in the past few releases of VSCode on OSX - even when selecting a block of code, right clicking and hitting "format code" it does nothing.

    And the autocompletion is very strange, when I write "if(" it often replaces it with "if(())"...

    Is anyone else having similar issues with developing for Unity in VSCode on OSX?
     
  16. xuanyusong

    xuanyusong

    Joined:
    Apr 10, 2013
    Posts:
    49
    大胡子哥哥, 你为什么这么帅? 哈哈哈哈
     
    roger-wang likes this.
  17. Hank9527

    Hank9527

    Joined:
    Nov 25, 2015
    Posts:
    2
    活捉野生unity大神一只
     
  18. The-Little-Guy

    The-Little-Guy

    Joined:
    Aug 1, 2012
    Posts:
    297
    Yes it does :)
     
  19. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    :) cool !!!
     
  20. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Why is the installation process so cumbersome ? is there any work that is being done to improve that ?
     
  21. Cybexx

    Cybexx

    Joined:
    Dec 4, 2008
    Posts:
    23
    It looks like the namespace issue was fixed today in VS Code version 0.10.2. The main thing for me now is that the codehinting for constructors often doesn't like to display.
     
  22. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Because this is a preview release. The installation process will become easier over time.
     
    Shushustorm and liortal like this.
  23. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    your guys save my macbook.
     
  24. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    there is UnityVs a part of visual studio.. any difference between this product and that one?
     
  25. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Yes, there is difference. Visual Studio Tools for Unity (VSTU, previously UnityVS) contains a separate implementation of a debugger client for Unity's Mono runtime and currently only available for Visual Studio. VSTU was developed by SyntaxTree, who have since been acquired by Microsoft.

    This VS Code Unity debugger extension is a separate open-source product which is based upon the Mono debugger client also used in MonoDevelop: https://github.com/Unity-Technologies/vscode-unity-debug
     
    twobob likes this.
  26. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    Thanks for your detailed reply. It's obvious that these products have been developed by different companies.. my question was in terms of usability/features/etc..

    Cheers.
     
  27. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    In terms of usability and features between VS Code and VS, I suggest trying them both and use the one you find to be the best tool for the job.
     
    DalerHakimov likes this.
  28. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    No ReSharper or any sort of standard refactoring kills VSCode for me. Big hopes for a ReSharper coming for it now that it supports plugins.

    For now I recommend Consulo for OSX development, it's basically IntelliJ community with C# and Unity plugins. All free and well supported, does pro refactoring, breakpoints and code completion.
     
    mollermanden likes this.
  29. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    @MaDDoX, I've tried ReSharper a few years back, it was too slow, had to uninstall it. I tried it just recently again on a much faster PC - still no go. Sometimes it's fine, but most of the time VS with ReSharper gets too slow, it lags a second or two behind my keyboard... Uninstall seems to be the only useful function in it ;)

    You may have a fast PC, I don't know, but the whole thing about ReSharper doesn't sound good. It runs on Java and does its own code analysis, while VS runs on .Net while doing its own code analysis. Then all that needs to run simultaneously with Unity that runs on Mono. I guess all that combined kills the performance for me.

    I've tried Consulo as well just now, I didn't know about it before you mentioned it... I tried the PC version and I can't say I'm impressed - it feels kind of laggish even without any fancy plugins, auto-completion is case-sensitive, and it took me so much time to open a project... I didn't go any further than that, I saw enough :p
     
    ramand likes this.
  30. bayview

    bayview

    Joined:
    Apr 3, 2014
    Posts:
    7
    Seems didn't work on Linux,i set the breakpoint,click the green triangle,and the DebugBar show for less than 1 second,than dispeared.
    i switch to Unity ,press the Play button,and nothing happen.Is there somebody facing the same issue?
     
  31. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Thanks for this plugin :)

    It works on Linux! I'm also trying to replace Visual Studio by VS Code on Windows because it's lighter.
     
  32. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Do you have a recent version of the Mono framework installed? You could try running the "mono UnityDebug.exe" in the bin folder (which is what VS Code does when starting a debug session) and see if you get an error message that can help you diagnose the issue. I will add more logging in future versions to make it easier to track down issues.
     
    Last edited: Nov 30, 2015
  33. CPXTom

    CPXTom

    Joined:
    Apr 24, 2010
    Posts:
    113
    This has changed my life. Thanks!
     
  34. Travis_Foo

    Travis_Foo

    Joined:
    Jun 26, 2015
    Posts:
    7
    I don't know if this a silly issue, but: the first time I set up the debugger it works great. But as soon as I press play in the Unity editor, it overwrites the launch.json file, changing the name to "Unity" instead of "Unity Editor", and type to "mono" instead of "unity". This creates an error: " initialize: can't create debug session for adapter 'mono' " and prevents me from debugging. It also adds a port number which doesn't affect anything. Only changing changing the name and type back to the originals will allow me to debug again.

    EDIT: Figured it out. The Unity Integration plugin was overriding it. All I had to do was uncheck the "Always Write Launch File" option in the Unity preferences.
     
    Last edited: Nov 30, 2015
    routitsm likes this.
  35. bayview

    bayview

    Joined:
    Apr 3, 2014
    Posts:
    7
    Failed to find the "mono UnityDebug.exe" in the bin folder,Since someone has made it right,I will figure it out,Thanks for your reply,Nice job on linux,I'm loving to deliver my job from windows to linux.
     
  36. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    The "mono" part of the command is the Mono .NET runtime that is used to run the UnityDebug.exe, so "mono UnityDebug.exe" means that you run UnityDebug.exe with the mono runtime installed on your system. See install instructions for how to install Mono on your system.
     
  37. IntDev

    IntDev

    Joined:
    Jan 14, 2013
    Posts:
    152
    Is there intellisense support? :(
     
  38. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    pkr1234 and IntDev like this.
  39. mollermanden

    mollermanden

    Joined:
    Apr 2, 2013
    Posts:
    23
  40. TerrenceRao

    TerrenceRao

    Joined:
    Jun 19, 2015
    Posts:
    5
    Great work.
    It take me long time to diff ".vscode folder" in my unity project folder and Home Folder.but it's ok now
     
  41. pkr1234

    pkr1234

    Joined:
    Nov 7, 2015
    Posts:
    2
    I want to help MonoDevlopment with c# in unity
     
  42. faraz

    faraz

    Joined:
    Aug 4, 2014
    Posts:
    46
    This is looking good i will try!
     
  43. xCyborg

    xCyborg

    Joined:
    Oct 4, 2010
    Posts:
    632
    Great, I hope either Unity or VSTU supports Code natively like VS by the time the final release hits.
     
  44. Shushustorm

    Shushustorm

    Joined:
    Jan 6, 2014
    Posts:
    1,084
    Awesome! Thanks!
     
  45. ArmanOhanian

    ArmanOhanian

    Joined:
    May 2, 2015
    Posts:
    6
    Exciting! I wasn't very interested in having to open Visual Studios or Monodevelop just to edit a simple script!
    VSCode is much faster. I will definitely give this extension a try! Huge Thanks!
     
  46. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Version 0.5.0 is now available. Download link in first post.

    Release Notes

    Version 0.5.0
    • Added support for attaching to Windows, OSX, Linux, Android and iOS players
      Regeneration of the launch.json is required to get the players in the debug configuration list.
    • Added log file
      • OSX/Linux: ${HOME}/.vscode/extensions/UnityDebug-log.txt
      • Windows: %USERPROFILE%\.vscode\extensions\UnityDebug-log.txt
    • Fix issue with "unity" being marked as unknown "type" in launch.json
     
  47. darkoverlordofdata

    darkoverlordofdata

    Joined:
    Nov 18, 2015
    Posts:
    6
    This is working great for me on Linux. I much prefer Code to MD. You should submit this to the VS Marketplace.
     
  48. roger-wang

    roger-wang

    Joined:
    Jun 8, 2013
    Posts:
    11

    see you here, again.
     
  49. LTK

    LTK

    Joined:
    Jul 16, 2015
    Posts:
    24
    Very goode extension. Thanks!
    PS: I type "///" but VSCode not auto generate summary
     
    Last edited: Dec 11, 2015
  50. Sajid

    Sajid

    Joined:
    Mar 12, 2011
    Posts:
    199
    Any way to make the cmd.exe stop popping up whenever I open a script in VSCode? I'd love to use this software but that drives me absolutely crazy.

    Also, when trying to use debug I get this:
    Running windows 10 and I have the VSCode plugin from the assets store installed.

    Edit: I needed to change the launch.json.

    This is my launch.json:
    Code (CSharp):
    1. {
    2.     "version":"0.1.0",
    3.     "configurations":[
    4.         {
    5.             "name":"Unity Editor",
    6.             "type": "unity",
    7.             "request": "launch",
    8.         }
    9.     ]
    10. }
    but when I try and debug I get this:
    Also, syntax highlighting does not appear to be working.
     
    Last edited: Dec 11, 2015