Setting up Unity 2019.x with VSCode on Ubuntu 18.04 LTS: A Troubleshooting Guide

Image for post
Image for post

I’m a game developer on Ubuntu 18.04 and Unity. I’ve been putting up with monodevelop on my 4K monitor. Gnome desktop (the default desktop manager on Ubuntu) supports UI scaling, but older apps don’t quite work with UI scaling. So today after upgrading my Unity to 2019.3 to report a bug (you have to report bugs on the latest version to get any attention), I also decided to setup vscode. It should take ten minutes tops I thought… and man was I wrong. It took me around 2 hours to try out a few dozen things and read half of posts on stackoverflow tagged #omnisharp and so forth.

Long story short, there are a bunch of hoops you have to jump through to get everything working. I’m only going to mention things at the high level and problems I encountered in the hopes that it will help someone else setup their IDE faster.

Install Unity Editor

Start by installing Unity Hub:
https://docs.unity3d.com/Manual/GettingStartedInstallingHub.html

I like the new version of Unity Hub on Ubuntu because it worked. Through Hub UI you can install Unity 2019.2 or (2019.3 if you feel on the edge). Now grab a cup of coffee, it will take a few minutes for it to install specially if you have Android or iOS build modules included.

Once installation finishes create a project and make sure you run the project.

Install Visual Studio Code (VSCode or Code)

Installing VSCode and making it understand Unity’s C# projects is the tricky part. You can install VSCode from different sources. I used apt:

$> sudo apt install code

Tell Unity to use VSCode

In project preferences -> external tools you can tell Unity what program to use for editing c# scripts. If you have the Visual Studio Editor packages in your project (Picture 1), you should see a special “Visual Studio Code” option in your preferences (Picture 2.). The packages are part of the standard Unity download now.

Image for post
Image for post
Picture 1. VSCode packages
Image for post
Image for post
Picture 2. Setting Visual Studio Code as the external editor for c#

At this point double-clicking scripts opens VSCode but VSCode fails to open projects with:

Failed to spawn dotnet --info

So we continue!

Install dotnet

Install dotnet from the link below. No surprises here.

Install mono-complete

I initially installed the default mono-devel package and ran into errors in VSCode:

Error: The reference assemblies for framework “.NETFramework,Version=v4.7.1” were not found…

The error message would go on to say install the right package. Really helpful!

Follow the instructions from here for installing mono but install mono-complete package instead of mono-devel.

$> sudo apt install mono-complete

Done!

For me everything started working at this stage. I have code completion in VSCode and am using Unity 2019.2.x. Hope this helps.

If you followed these instructions on your Ubuntu 18.04 LTS and still couldn’t get it working, feel free to contact me. I’d be happy to help :)

Written by

Software Engineer | Indie Game Developer | Founder of No Such Studio. Follow me to learn how to make video games with Unity. http://www.nosuchstudio.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store