Use Unity while coding with VSCode elegently on Ubuntu 22.04 LTS


Install VSCode from one of the following ways

  • Download .deb from official download link
  • apt
  • Ubuntu software (snap)

Install Unity Hub and Unity Editor

You can follow this link to install Unity Hub from apt.
Then you can install Unity Editor inside Unity Hub, and create a new project.

Settings in Unity Editor

Open the new project. In the project’s top menu bar, select Edit -> Preferences...
In the window, find External Tool option at the left side menu, and in the right-side External Script Editor option, switch it to Visual Studio Code.
Then, check all options under Generate .csproj files for: title and click Regenerate project files button.

Install dotnet-sdk and mono

In this section, try your best to make sure the version is exactly the same with me. I cannot promise other versions are fine, even though the version may vary little.

  1. Install dotnet-sdk-6.0.400 from here. Note: you need to add dotnet to $PATH so that VSCode can find it.
  2. Install mono- from here. Note: at the time I post this, there’s no Ubuntu 22.04 section in mono download page. I use the exactly same commands with Ubuntu 20.04 section and it works.

You can check whether the version is correct by the following commands

dotnet --version
mono --version

Final settings in VSCode

You are almost there, just a few steps!

  1. In VSCode, install the c# extension.
  2. In c# extension setting, uncheck Use Modern Net option.
  3. In c# extension setting, fill in the Mono Path with the output of command which mono.
  4. Restart your PC.

A replace of VSCode

As many have complained that VSCode in Ubuntu is hard to configure, here’s a replace of VSCode: JetBrain Rider!
This is a cross-platform .NET IDE based on the IntelliJ platform and ReSharper.

Link: Rider: The Cross-Platform .NET IDE from JetBrains

This IDE doesn’t need any extra effort and can be used for programming in Unity perfectly. Just download it in your Ubuntu and open your Unity project in it!