Unity with VsCode in Linux (Fedora 38)
Greetings
Hello, fellas. I recently swapped to a new Linux distro, Fedora 38, and I found out that making Unity work properly there is not a 5-minute task. There is no complete tutorial for that, so I decided to make one.
I recommend Ubuntu 22.04 LTS more, that Fedora, for users with weak PCs, because of performance. This tutorial is still valid for Ubuntu (if you use setup for weak PC), just change "dnf" to "apt-get" and install dotnet sdk 6 instead of 7.
Let's go ahead and get started!?
Table of content
System update
First, before installing anything, update your system. This can take some time if it was recently installed. Type the following in your terminal and press Enter:?
sudo dnf update
UnityHub installation (credit)
There is the first potential issue. One might be tempted to open the " Software " application and download Unity Hub from there, but this is a suboptimal solution, because:?
The correct method is to use the terminal again. Acclimate yourself to it if you have not yet; it will be used throughout this tutorial and also in Linux in general.?
The next command to copy-paste adds UnityHub to the repository:
sudo sh -c 'echo -e "[unityhub]\nname=Unity Hub\nbaseurl=https://hub.unity3d.com/linux/repos/rpm/stable\nenabled=1\ngpgcheck=1\ngpgkey=https://hub.unity3d.com/linux/repos/rpm/stable/repodata/repomd.xml.key\nrepo_gpgcheck=1" > /etc/yum.repos.d/unityhub.repo'
And following updates cache and installs (if this not working, try to change "dnf" to "yum"):
sudo dnf check-update
sudo dnf install unityhub
After that you should be able to open it with unityhub terminal command. Or simply access it through Fedora application menu.
Unity
Installation
Open up UnityHub and after you sign-in you should see an installation window. Which looks like that, but with a Linux installation path.
You can click the "Install Unity Editor" button to install the last LTS version, but you can also skip the installation and install a different version by?
I prefer the last option.?
Problems
If you whenever face the "There is not enough space to download and install the selected items" problem during the installation, which I did, open your terminal and make a "tmp" directory in your main user folder (home folder).
mkdir ~/tmp
Then, in UnityHub, open Preferences -> Installs and change the Download location to just created folder. In my case, it looks like this.
领英推荐
VsCode
Installation (credit)
As mentioned earlier, VsCode from "Software" is not our choice. To install it properly, type in the terminal following to install the VsCode key and repo:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.as
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'c
And this will update package cache install VsCode itself.
dnf check-update
sudo dnf install code
Get started
Create a new Unity project and open it. Next, open up?Unity Preferences ->?External Tools, then select Visual Studio Code as?External Script Editor.
You also need to install dotnet SDK, so write this command to you terminal:
sudo dnf install dotnet-sdk-7.0
Set-up for powerful PCs
It's quite simple:
Set-up for weak PCs
sudo apt-get install mono-complete
If auto-completion does not work
Note: give step time to take effect, don't go to the next step immediately.
Performance improfements
It is important to make programs less demanding for weak PCs. Fortunately, Linux has a "nice" command to address this issue. This command helps to prioritize programs by setting their niceness.
To launch Google Chrome, type?
nice -n 15 google-chrome
To launch Unity, type the command below, and then select the folder containing your Unity project.?
nice -n 13 /home/<YOUR USER NAME>/Unity/Hub/Editor/<YOUR UNITY VERSION>/Editor/Unity
Change words in <> to something sensible in your case. That path may be slightly different depending on the Unity file location.?
You can obtain additional information about the nice command by entering it into the terminal command below.?
man nice
I use the exact same values after- n when I work with Unity and Google in conjunction.?