**Updated for Version 1.0.0 - be aware there are some new "Getting Started" extra points, like installing C#, which is no longer installed by default.
I’ve written several articles on the use of VSCode with Unity through its evolution but time and tide waits for no man as the behemoth of technology marches on.
If you’ve not heard of Microsoft’s new multi-platform lightweight code editor before, go and check out https://code.visualstudio.com/, it’s chock full of fantastic stuff to make you drop MonoDevelop or any other lightweight editor. You can also check out my previous articles here and here.
Microsoft VSCode has taken many great strides since last I donned my writing hat, most notably:
There is a lot more but these are my favorite highlights. If you have read my previous articles on the subject (here and here), you will also know that it has some great support for Unity, which has only gotten better now that Unity themselves have pulled in to the race:
Since the early beta releases we’ve been able to configure VSCode manually as a code editor within Unity, slowly but surely through the beta phases this integration has been improved to add file and line support when calling VSCode.
Back in VSCode Version 0.8.0, this took another bold leap forward with its first Unity asset (well, the only really) aimed at providing increased integration between these two products.
Made by a community developer with some assistance from teams at Unity and Microsoft, they automated a lot of the menial setup required to make the most out of the integration, namely:
Plus a host of other little tidy up / backend tweaks needed to ensure it all worked seamlessly.
The only real limitation in its use was that debugging was only supported on a Mac (granted Mac owners didn’t see this as an issue ), UNTIL NOW!!
The train never stops when it comes to technology (even Cobol still lives!, granted Flash and Silverlight are headed to the graveyard), especially when a project becomes opensource but is still heavily contributed by the project originators, which in this case is Microsoft. They are certainly on a mission to make the fastest and most powerful cross platform editor out there.
Recently Unity Technologies themselves also wrote an extension for VSCode to allow debugging of Unity projects from more platforms:
With this extension installed you can now simply attach your VSCode project to Unity in a very similar way to what is possible already with the Visual Studio Tools for Unity with Microsoft Visual Studio (which also replaced the default code editor on Windows and is now bundled with Unity), this includes such support as:
Unity have also made the extension itself opensource on Github (like so many of their other new initiatives, the UI and 2D updates to name a few), so if there is something you feel is missing or could be done better, you can either build your own or submit a pull request and send it to Unity to add.
**There is also an additional community VSCode addon which gives you both Unity and VSCode document lookup support and a few other nice features, worth checking out.
Enough talk, let’s get this up and running in a few short steps, it’s easy enough but the information is slightly scattered throughout the interwebs and pages.
The short path to get this running is as follows:
Almost there, we now have all the necessary components installed, however to enable debugging, there is one final step.
If all goes well you should see a new “Launch.json” configuration file in the viewer showing you the current debugging options available.
If anything goes wrong or it doesn’t look right, then simply return to the folder/files view (top left folder icon) and delete the Launch.json file, then repeat the above steps which will recreate it.
You should be able to determine from looking at the default launch configuration that it only supports the Editor by default, however you can extend this to support projects too if you wish, just check the marketplace support page for more detail – https://marketplace.visualstudio.com/items/Unity.unity-debug
All done, if you return to the Folder/File view you can set breakpoints as you would do in any other code debugger and have VSCode break on that line when it’s hit.
Let’s see it in action:
I don’t think this is the end for VSCode’s integration with Unity, especially not with everything being opensource, so the future is looking very bright for Unity developers!
I'm Simon Jackson, [email protected] MVP and all round game development evangelist, working with any game development technology I can get my hands on (I haven't got a HoloLens yet, but I certainly want one!). Additionally I'm an active contributor and supporter of several open source projects, including the everlasting XNA evolution that is MonoGame and the amazing AdRotator advertising/monetisation platform.
On top of that I'm also a best-selling author of two Unity titles, which are doing very well at the moment with many great reviews, as well as running an opensource project to collate all the great UI Extensions the community has to offer under one asset (https://bitbucket.org/ddreaper/unity-ui-extensions).
You can learn more about me, my projects and titles on my blog.