Visual Studio Code can be a great companion to Unity for editing and debugging C# files. All of the C# features are supported and more. In the screen below you can see code colorization, bracket matching, IntelliSense, Code Lens and that's just the start.

Read on to find out how to configure Unity and your project to get the best possible experience.

Note: VS Code uses a more recent version of Mono than that included with Unity. If you get OmniSharp errors, you may need to update your Mono version. See this FAQ topic for additional details.

Connecting Unity and VS Code

The easiest way to get going is to leverage a Unity plug-in maintained by @Reapazor. This plug-in streamlines the integration process significantly by performing the following tasks:

Sets VS Code as the default editor - opening a script now opens it in VS Code

Configures Unity to pass file and line numbers and reuse the existing window - so VS Code opens in the correct context

Scrubs the Unity project file to ensure that OmniSharp can work with it - to get the best editing experience

Today (September 10th) marks another notch in the VS Code journey to become THE lightweight multi-platform editor, the one editor to rule them all.

If you’ve been following previous articles of mine and others, there has been a big push to use VS Code’s C# features with Unity and to integrate them together seamlessly (well almost)

This wasn’t without pain however:

When you opened VS Code for the first time, you had to go through a process to open your project folder to get Intellisense working

If you accidentally closed VS Code, you had to repeat the above again

If you were working on multiple project, well it was a pain.

Unity does not have a concept of a folder when launching an external application, so couldn’t help.

Most devs however were happy to live with these constraints as the flexibility, power and speed they got from using the editor.

That is until NOW.

Enter VS Code Version 0.8.0

The VS Code team haven’t been sitting on their laurels, they have listened, they have watched and through it all (with the help of the community) they have acted.

As of 0.8.0, the Unity integration has gotten even tighter and most of the old hindrances have been cast aside, giving developers a much more fluid working environment (and if you are on a MAC, it’s even better #Grumble)

In the previous videos we discussed how to integrate Unity and Visual Studio Code from scratch. But thanks to Unity plugin from @reapazor you can simplify this work.

As you know, it’s possible to use Unity plugins to extend Unity interface and execute almost everything. If you have source code of a Plugin you simply need to place it anywhere in the Assets folder and Unity will compile it on fly and use attributes there to extend the standard menu.

The VS Code plugin contains one source code file only, so, you can clone the full repository using

git clone https://github.com/dotBunny/VSCode.git

or extract the file itself from zip package.

In my experiments I am using Unity3D 5.2, so it’s not very important where to place this file. For example, you can place it as before using Plugins/Editor folder or you can select any other folder in your Assets tree.

Once you add the file to your Assets folder, Unity will compile it, and you can find new menu item using the context menu or Assets menu item: Open C# Project in Code.

Using Open C# Project in Code you can open Visual Studio Code and it will open the right catalog and select the right project by default. But the plugin supports much more things. In order to see al features there, let’s open Unity->Preferences and you will find VSCode there:

Let’s make a short overview to the options there:

Enable Integration – if this option is checked, you can use VS Code as the default editor. This option should be on by default but you can change it any time instead by using Unity->Preferences->External Tools tab;

Always Write Launch File – by default you cannot debug the project. In order to enable debugging you need to create launch.json file and configure it. But the plugin can create the launch.json for you. In order to do it you need to enable this feature, turning on the checkbox and run your project from Unity editor. The plugin will read information about the debugging port and update/create launch.json file;

Write Workspace Settings – If you open your project in VS Code you can find lots of different files that you don’t want to see. It’s easy to fix, add your own settings for the workspace and exclude all not needed files. Using this button, you can do it automatically – just click it;

(the latest version contains one more checkbox and a button that allow to update the plugin without visiting GitHub).

So, as you can see we spent less time than before in order to integrate Unity and VS Code using the plugin. ...