Installing Unity on Distrobox

linux
_guides
Published

October 27, 2024

First, begin with installing distrobox and podman, on your respective distro.

Here’s how to do it one some of the major distros:

pacman -Syu distrobox podman
apt update && apt install -y distrobox podman
dnf install distrobox podman

Then, create an Ubuntu 22.04 container, since that is what Unity officially supports.

distrobox create --image docker.io/library/ubuntu:22.04 --name unity

Then, you can enter the container:

`distrobox enter unity

From here, follow the steps on Unity’s official site:

wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor | sudo tee /usr/share/keyrings/Unity_Technologies_ApS.gpg > /dev/null
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/Unity_Technologies_ApS.gpg] https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list'
sudo apt update && sudo apt install unityhub

After this, install Microsoft VSCode using their official steps

sudo apt-get install wget gpg apt-transport-https
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg
sudo apt update && sudo apt install code -y

Since we are doing unity development, we will also need dotnet-sdk-8.0, and git

sudo apt install dotnet-sdk-8.0 git

VSCode Configuration

There are several extensions that significantly enhance the C#, .NET, and Unity development experience.

ms-dotnettools.csharp — This is Microsoft’s C# and .NET extension, and it will pull a few extensions as a dependency.

VisualStudioToolsForUnity.vstuc — This is Microsoft’s official Unity extension.

Logging into Unity Hub

This process can be somewhat difficult, as Unity Hub will not show up on the desktop.

And for some reason, I needed flatpak on my host system (or more likely, one of it’s dependencies).

sudo pacman -Syu flatpak — or however your distro will install flatpak.

First, launch unity in the container.

distrobox enter unity
unityhub

Then, click the login button. A browser will be opened, asking you to login. However, you will not automatically be redirected to Unity Hub, from that page, you have to do it manually.

Copy the link on the bottom right. And then, in another distrobox session (Unity Hub must still be running for this to work)

unityhub [copied link]

If you need to install a specific version of Unity not available in the Unity Hub, this is a similar process. Go to Unity’s release archive, find the relevant link, and then copy the install link, and paste it like above.

Misc

One thing I like to do is use Zellij as a terminal multiplexer

cd /bin

sudo wget https://bin.ajam.dev/x86_64_Linux/zellij

sudo chmod +x zellij

zellij