How to Use Visual Studio Code to Develop Unity3D Projects in Ubuntu

How do I use Visual Studio Code to develop Unity3D projects in Ubuntu

Please note that the following instructions contain commands that are specific for 18.04. Please check the sources if you have a different version of Ubuntu or Linux.


1. Install the C# extension for Visual Studio Code

C# Extension Screenshot


2. Install the "Debugger for Unity" extension for Visual Studio Code

Debugger for Unity Extension Screenshot

3. Install the latest version of "Mono"

Mono is an open source implementation of Microsoft's .NET Framework sponsored by Microsoft. Instructions for a repository installation:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel

(Source). It also has instructions for 16.04 and 14.04.

4. Install dotnet

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.1

(Source). It also has instructions for 16.04, 14.04 and others.

5. Open your project's folder with Visual Studio Code

Screen photo, opening project folder with Visual Studio Code

6. Set the "Unity Debugger" in Visual Studio Code

Select the debug view on the left and click the cogwheel.

Screenshot 1 from Github

In the drop down list select “Unity Debugger”. If you do not have Unity Debugger in the list, then you already have a .vscode/Launch.json file in your project that you must delete first.

Screenshot 2 from Github

You will now have a .vscode/Launch.json file in your Unity project folder and can select which Unity target you wish to debug.

Screenshot 3 from Github

(Source).

Unity3D on Ubuntu 19.10 with vscode and C# extension : get an error and the autocomplete doesn't working

This warnings is a known Visual Studio Code Editor 1.1.4 bug.
According to this information, it's Omnisharp extension that is causing the error:

This issue is caused by an extension, please file it with the
repository (or contact) the extension has linked in its overview in VS
Code or the marketplace for VS Code. See also our issue reporting
guidelines.

Happy Coding!

For me, downgrading to version 1.1.3 of the package fixed the problems.

In UnityEditor go to: [Window]->[Package manager]->[Visual Studio Code Editor]->: Select 1.1.3 version and click to "Update 1.1.3" Button.

Sample Image

If the errors don't go away after that:

  • 1) Changed "com.unity.ide.vscode": "1.1.3" in "Packages/manifest.json"
  • 2) In UnityEditor go to: [Edit]->[Preferences]->[External Tools]: Set "Generate all .csproj files" CheckBox to true.
  • 3) In UnityEditor go to:[Assets]->[Reimport All]

Some people say that, if you downgrade to 1.1.3 and right after upgrade to 1.2.0 errors should be fixed, but I haven't tried it.

Visual studio code Intellisense not working with Unity Engine?

Finally solved the issue.

First had to make sure that it wasn't a duel drive problem with Unity on D: drive and VS Code on C:

and then after reinstalling that when you open a C# file the IntelliSense may still not work.

To fix that I had to select Assets > Open C# Project After you do that if you open a C# script even just by double clicking the IntelliSense works fine.



Related Topics



Leave a reply



Submit