20

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.

0

1 Answer 1

33

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

5
  • 1
    Fantastic answer. Very in-depth and detailed. If I had to use VSC I'd be completely lost trying to set it up myself! Thankfully I have a license for Visual Studio proper, so I can use what Unity magically installs for me. Oct 14, 2018 at 23:40
  • @Draco18s the reason to prefer VSC while developing often is the fact that it opens up way faster than VS does.
    – derHugo
    Oct 15, 2018 at 5:12
  • @derHugo Nothing wrong with that. :) I just remember a time when VS wasn't distributed with Unity and I tried to set it up (after having gotten frustrated at MonoDevelop) and was unable. Oct 15, 2018 at 14:17
  • For anyone who is having problems with intellisense, auto complete after installing VScode. Here are some suggestions: - Be sure of having dotNet. - Select VScode from Unity->Preferences->External Tools->External Script Editor->Browse - Some suggest to change "External Script Editor Args", which is just below "External Script Editor" tab, to $File$ but instead of that I clicked "Reset Argument". And It did work for me. - Install correct extensions in VScode. You can find them here: code.visualstudio.com/docs/other/unity I hope these may help. Sep 27, 2019 at 13:06
  • Very fantastic answer. I suggest also this link: mono-project.com/download/stable/#download-lin Jul 12, 2020 at 8:05

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.