Search Unity

Visual Studio Code

Discussion in 'Scripting' started by IQpierce, Apr 29, 2015.

  1. IQpierce

    IQpierce

    Joined:
    Jan 24, 2011
    Posts:
    43
    https://code.visualstudio.com/

    A news story: http://9to5mac.com/2015/04/29/microsoft-visual-studio-code-mac/

    Microsoft describes the program as a “code optimized editor” with support for Intellisense, debugging, and GIT. The developer tool also features integration with GitHub.
    This is exciting news for me: Mac is my preferred platform for most purposes, and it's easier to create iOS apps from a Mac OS X environment.

    I've worked in Unity exclusively on Mac. However in my past life as a games industry programmer, I worked on Windows machines in Visual Studio. It was always a very powerful and reliable IDE with the most fully-featured debugger I knew, and a large selection of productivity tools.

    I like Unity's MonoDevelop more than most folks - I like that it has powerful refactoring tools and very good autocomplete, and deep customization for automatically following a coding style... and of course the debugger is a powerful tool, and on Mac the only way to attach to it is through MonoDevelop.

    However, in almost every other respect, Unity-MonoDevelop on Mac is... well, it F***ing sucks. It's Bush League. It can be very fast and smooth at times, but it will often become sluggish and slow to respond, or will freeze completely. I've been using it since 2011 and only yesterday did I realize that when you open the "attach to debugger" dialog, you have to choose an option on the dialog *within three seconds*, and if you don't, MonoDevelop will freeze and never recover. Unbelievable. I've talked to many developers who dual-boot, or work with Windows emulators, just so they can use Visual Studio with Unity from the Mac... but those options have never seemed practical to me.

    The original creators of MonoDevelop, Xamarin Studio, have repeatedly said publicly that modern Xamarin has fixed almost all of these types of problems in the original MonoDevelop... and that all Unity had to do was pull their changes into their branch and bring Unity-MonoDevelop up-to-date, and the editor would be greatly improved. Yet I've never seen a Unity dev even express the intention of doing this. It literally feels like Unity doesn't care about coders who work on Mac, and the fact that those coders have no really good options for code editors right now.

    I hope Visual Studio Code will change that situation. At this point I've given up any hope of Unity taking the maintenance of MonoDevelop for Mac seriously - but if the Unity Editor can be integrated with Code on Mac, maybe I can finally have a good option for coding on my favorite platform.

    I don't have time to try Code just now, I'm behind on my current tasks... but I had to start a thread about this. (I'm behind on work in part thanks to MonoDevelop being constantly flaky, so I admit I'm venting about the situation a bit in this post.) But I hope to try this new editor, and look into hooking it up to Unity, within the next few days....

    Until then, I thought I'd start a thread to discuss this, as I think it's important! If you have a chance to try hooking them up, please post about it here, let's share some knowledge!
     
    Andrey-Postelzhuk and rakkarage like this.
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Don't waste your time. It's barely more than a text editor. It doesn't have Intellisense (at least insofar as Unity files are concerned) and its autocomplete is painfully unaware of its surroundings - it's literally just a list of keywords that it has found in your file. It certainly doesn't have the code refactoring or debug tools that MD has.

    This discussion is better suited to the External Tools board.
     
  3. IQpierce

    IQpierce

    Joined:
    Jan 24, 2011
    Posts:
    43
    It explicitly says that it has debugging and Intellisense. If Unity could integrate with those parts of the tool, and if Code has the small performance/memory footprint of a text editor, then it would already be an improvement on MonoDevelop.

    I'll try to figure out how to move this thread to the External Tools board I guess.
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I think it has those things for Javascript/web dev. It doesn't have any way to link up to the Editor process like MD can.

    As for the performance/memory.... well, there's a reason I put up with those in MD, and it's because of all of its extra features (which VSC very much does not have.)
     
  5. Deleted User

    Deleted User

    Guest

    "and very good autocomplete"
    Really? MD's auto is terrible for me.
     
    devbr likes this.
  6. IQpierce

    IQpierce

    Joined:
    Jan 24, 2011
    Posts:
    43
    Why wouldn't it? Visual Studio for Windows can connect to the Unity Editor process by attaching to the debugger. The editor explicitly has a section for connecting to an "External Script Editor" with a checkbox to allow it to attach the debugger to that tool. Seems it would be, at worst, some simple work for Unity to connect them together?

    FWIW it looks like there's already a thread for this (I didn't see the External Tools board): http://forum.unity3d.com/threads/visual-studio-code-edition-mac-linux-windows.322373/

    ...I'm going to move this conversation there since people are already talking about hooking this up. Also this post seems to have a relevant poll: http://forum.unity3d.com/threads/will-visual-studio-code-replace-monodevelop.322354/#post-2091051

    In any case, ignore this thread, sorry for missing that there was an existing discussion.
     
  7. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I'll stop you right there. This thing isn't Visual Studio.
     
  8. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    This thing isnt Visual Studio, it is more on par as sublime for the kinda role it plays. It also is no good for Unity Dev, since it dosnt support Visual Studio Extensions to no debugger attaching and it dosnt seem to be aware of the Unity API and cant auto complete for it.

    If you really want Visuals Studio Community or Pro on OS X i would recommend you use paralleles to make a windows virtual machine and run VS in that.

    I have had great success doing so from OS X by keeping my project in a shared folder, and letting the debugger attach via a udp port on the lan.
     
  9. Torninator

    Torninator

    Joined:
    Jun 17, 2014
    Posts:
    11
    Incorrect - see this post here for how to attach your -csharp.sln file: http://forum.unity3d.com/threads/will-visual-studio-code-replace-monodevelop.322354/#post-2091269

    The only thing missing is proper integration with unity debugger -- if Unity or MS can add this, Monodevelop would be dead in the water
     
    IQpierce likes this.
  10. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    Seems like a logical next step, currently I develop on a pc then push to a mac and build from there because using monodevelop is terrible. Unfortunately I still have to use monodevelop some when I have errors on the mac build. I tried out Visual Studio Code earlier and it can't even open a .sln so I'm not holding my breath.
     
  11. Foriero

    Foriero

    Joined:
    Jan 24, 2012
    Posts:
    584
  12. big_march

    big_march

    Joined:
    Mar 2, 2015
    Posts:
    38
    I just found a tutorial about using vsCode in unity3d at this time.
     
    Last edited: May 3, 2015
  13. Callski

    Callski

    Joined:
    Feb 3, 2013
    Posts:
    130
    @big_march this was exactly what I needed! Your linked video had me up and running on the mac in under 5 minutes. Thank you so much!
     
    Last edited: May 5, 2015
  14. big_march

    big_march

    Joined:
    Mar 2, 2015
    Posts:
    38
    You're welcome:)
    At this time, this is not perfect, as all files(meta, asset, mesh, texture) in unity project paths would be included in vsCode.I've not found a better way yet.I think customizing any plugin of vsCode would solve this problem.I'm looking forward someone to share this.
     
    Last edited: May 6, 2015
  15. Jordii

    Jordii

    Joined:
    Sep 14, 2010
    Posts:
    135
    It's still too bad vsCode doesn't automatically fix stuff like missing 'using'. This is something I use a lot in Xamarin Studio (newer version of MonoDevelop). I love the lightweight feel, but I need this for it to be chosen over Xamarin. And I'm not sure this will be a feature for vsCode.
     
  16. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,433
    btw. one plugin here,
    "Unity3D editor plugin to make Unity projects Visual Studio Code compatible and add Unity/shader syntax highlighting"
    https://github.com/kode80/VSCUnity
     
    SAOTA likes this.
  17. Jordii

    Jordii

    Joined:
    Sep 14, 2010
    Posts:
    135
    I think this is possible without a plugin, right?
     
  18. Aram-Azhari

    Aram-Azhari

    Joined:
    Nov 18, 2009
    Posts:
    142
  19. cyuxi

    cyuxi

    Joined:
    Apr 21, 2014
    Posts:
    49
    Great! vsCode works perfect with Unity in CSharp, the auto completion is just working great!
    But what about Javascript? anyone knows how to configure the vsCode to recognize .js.
     
  20. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    It will never properly support what unity calls JavaScript since what unity calls js and what js really is are too very different things. Pretty much would have to wait till vs code supports extensions than wait for a unityScript plugin
     
  21. wkwan

    wkwan

    Joined:
    Sep 14, 2014
    Posts:
    27
  22. Aram-Azhari

    Aram-Azhari

    Joined:
    Nov 18, 2009
    Posts:
    142
    I haven't tried yet.
     
  23. coderage

    coderage

    Joined:
    Mar 5, 2015
    Posts:
    3
    I have been able to attach the VS Code debugger to Unity 5.0.2p4 using the following launch settings:

    Code (JavaScript):
    1. {
    2.     "version": "0.1.0",
    3.     "configurations": [
    4.         {
    5.             "name": "Unity",
    6.             "type": "mono",
    7.             "address": "localhost",
    8.             "port": 56943   // <-- Change this to the current port number
    9.         }
    10.     ]
    11. }
    12.  
    There are 2 problems that I've run into with it. First, the port that the debugger needs to attach to changes every time I start the editor or my game. I've had to go into the OSX Activity Monitor each launch and pull up the "Open Files and Ports" tab in the process info panel for Unity to get the current number. The port seems to always be the one between 56000 and 57000. There's probably a way to script this but it's working well enough for me for now.

    Second, pressing the stop button causes the editor to hang. What I've been doing is opening the current project in one window of Code and the folder above it open in a different window. I leave the window with the parent folder attached to the editor for debugging and edit in the window that has the current project open.
     
  24. xAvatarchikx

    xAvatarchikx

    Joined:
    Aug 17, 2012
    Posts:
    69
    Hi! And you can make a video ?
     
  25. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Is there any advance on this? I would really like to throw monodevelop away :p.

    Cheers.
     
  26. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    You can already use it just fine, its just attaching the debugger that doesn't work so well. Which is fine consider the monoDev debugger barley works.
     
  27. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    I'm using that. It may be a little bit annoying to be often selecting the project so the intellisense start to work. But it's still better than monoDevelop.
     
  28. BusStopStudios

    BusStopStudios

    Joined:
    Mar 28, 2015
    Posts:
    22
    Has anyone else had this issue. I double click a file and it opens in VSCode, set the project, go back to Unity and double click the same file but this time it opens up in a new window and doesn't have a project linked to it.
     
  29. Rob1508

    Rob1508

    Joined:
    Jun 25, 2012
    Posts:
    17
    I've just released a little workaround to get VSCode to open the file in an already opened window. (So you don't loose your project connection)

    You'll find it here: https://github.com/robin7331/UniArgs
     
    der_r likes this.
  30. Rob1508

    Rob1508

    Joined:
    Jun 25, 2012
    Posts:
    17
    UPDATE: This new script can also open your files at the correct line if you double click on a console error. And now there is no need for a mac app anymore since this is a simple script you place into your project folder.

    https://github.com/robin7331/UniVSCode
     
  31. Rob1508

    Rob1508

    Joined:
    Jun 25, 2012
    Posts:
    17
    @crgdev: are you still able to attach the debugger to VSCode? Even the port listed in the activity monitor does not work..
     
  32. Dosetsu

    Dosetsu

    Joined:
    Dec 22, 2011
    Posts:
    39
    @Rob1508 Great script! So nice to have this working.
     
  33. novashot

    novashot

    Joined:
    Dec 12, 2009
    Posts:
    373
  34. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    You can, with "VSTools for Unity", which is now owned by M$ and free to download and use. I have this feeling that I'm somehow missing the point of this thread entirely, or the entire thread missed the existence of "VSTools".
     
  35. coderage

    coderage

    Joined:
    Mar 5, 2015
    Posts:
    3
    Yep, I can still attach the debugger using the port from the activity monitor. I'm currently on Unity 5.1.0p1 and VSCode 0.6.0.
     
  36. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    on osx?
     
  37. eisenpony

    eisenpony

    Joined:
    May 8, 2015
    Posts:
    974
    I don't think VSTools is for Visual Studio Code - a separate and lightweight alternative to Visual Studio; also the only VS option for those on Mac OS.

    I agree the name "Visual Studio Code" is pretty lousy and very similar to the "Visual Studio code" I work on every day!
     
    Last edited: Aug 6, 2015
  38. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    That would explain the feeling I had of my having missed the point, thanks. I've never used a mac outside of university video editing course a decade ago, or had a problem with running the pro version of VS, so the name difference skipped right by me- my apologies.
     
    eisenpony likes this.
  39. coderage

    coderage

    Joined:
    Mar 5, 2015
    Posts:
    3
    yes
     
  40. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Last edited: Oct 23, 2015
  41. koblavi

    koblavi

    Joined:
    Oct 1, 2010
    Posts:
    52
    I set it up this weekend on OSX as well. Works beautifully. A lot snappier than MonoDevelop. Still a few quirks to iron out but I think on the whole it works much better than mono develop.
     
    jpthek9 likes this.
  42. darkoverlordofdata

    darkoverlordofdata

    Joined:
    Nov 18, 2015
    Posts:
    6
    I've started using Code+Unity in Linix Mint. I love it, it works better than monodevelop. I couldn't get the debugger to work in md anyway. I wouldn't expect that if Unity upgraded to a newer version of monodevelop that it would be any better. I've tried the 5.x versions on both Windows and Linux, and I couldn't tell you what or if got fixed. Same old buggy ide as 4.x
     
  43. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    I have struggled for a couple of hours now trying to get VS Code to work using the plugin. I managed to get past some dnx-related errors, but I still cannot get the project to read properly. I am stuck at this error:
    And the same applies to all the project files Code attempts to read. I do have project files present in the project folder but they lack the "-vs" addition, otherwise the names are identical to the files Code searches for.

    Any ideas where it goes wrong? Thanks in advance!
     
  44. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    Turns out that my problem was due to old project files lingering in the project folder. Removing them solved the problem. But now I have two other problems:

    1. Unity (5.2.3p3) will not write a csharp.sln. VS Code appears to open the project.sln file ok, but I am not sure if it works fully since all documentation indicates that VS Code should specifically be set to open the csharp.sln, not the "standard" non-csharp son.

    2. I get intellisense for some/most scripts, but not for editor scripts. So my custom editors (written i c#) get no peeking/definitions/autocomplete. Not sure if that is related to 1 above or some other setting. I have looked in the workspace settings for VS Code but did not find anything to exclude the editor folder.

    Any ideas?

    Many thanks in advance!
     
  45. Ches81

    Ches81

    Joined:
    Nov 27, 2012
    Posts:
    7
    Not sure if it fixes all your problems. But there is this helper "framework" that makes the integration of VSCode with Unity really easy. Like 3 clicks easy. It's called Unity Visual Studio Code Integration.
    Information about it can be found here. And here.
    I have code-completion, syntax highlighting and Unity console output clicks open the correct file etc.
    Cheers.
     
  46. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Is there a way to highlight Unity classes in VS Code? After VisualStudio that just must to be.
     
    Last edited: May 20, 2016
  47. Shaba1

    Shaba1

    Joined:
    Jan 21, 2010
    Posts:
    63
    i am hoping someone can walk me thru this problem that i have with vscode. on windows 7. I downloaded vscode from microsoft's site and installed it in a folder that I made on my desktop. NOT in the C:/program files(x86)/ directory. I did that so I always know where it is located. In anycase as a stand alone program vscode works just fine.

    i think downloaded the plugin from the asset store and added it to a project that I was working on. It seemed to install well. I think changed the location of vscode in the vscode section of unity preferences to that deskstop folder and changed the external editor to vscode. At that point was where i ran into problems.

    All scripts that were in that project now do not show up in the editor when you single click on them. When I try to edit those scripts I be an error in unity's status line to check my external preferences. Even when i try to switch back to notepad++ (which is what i was using before because it is so lightweight) I still cannot edit any scripts in that project.. I finally had to remove the .vscode folder from that project using windows explorer, because every time I tried to right click and delete it in the unity editor. then restart the project that folder just came back. Now even though the folder does not show up in the project panel anylonger i still cannot switch to any other external editor in that project and any script code in that project does not show up in the inspector.

    Luckily if I switch to any other project I can still open a script in notepad ++ and see the script's code in the inspector. So it just seems to be affecting the project that i used to download the addon.

    i know this is a very general description of a problem but can somone help me.
     
  48. kreso

    kreso

    Joined:
    Sep 7, 2013
    Posts:
    147
    Hello,
    using OSX & Visual Code and Intellisense does not work (Shows 'Loading...' for 10 seconds or longer before showing results). Neither does it show references.

    Anyone else?

    I have it working on another mac with same project, so it's not that project is too big or other ideas I saw at omnisharp github. I don't see any difference between the computers.

    I spent 20+hours trying to make it work (removing/updating components - mono, omnisharp, dnx, .net...), and it's very frustrating, as Microsoft suggested integration with Unity.
     
  49. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    Install mono
     
  50. kreso

    kreso

    Joined:
    Sep 7, 2013
    Posts:
    147
    Like my post says, I tried removing/updating mono.