Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have KDE neon (based on Ubuntu 18.04). I have installed the latest Linux version of Unity3D from this link.

I need a C# script editor to start developing C# projects. How do I setup Visual Studio Code to work with Unity3D projects? I need it to auto-complete code and underline compilation errors.

like image 787
Mina Michael Avatar asked Oct 14 '18 21:10

Mina Michael


1 Answers

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

like image 144
Mina Michael Avatar answered Sep 28 '22 03:09

Mina Michael