Unity provides a version manager and project manager called Unity Hub. Unity Hub automatically installs Unity versions of your choice and helps you create projects with each version.
Unity Hub is cross platform, so it is the simplest way to install Unity. Just follow the instructions of the installer to install it.
Unity Hub will prompt you to install the latest version of Unity. If you not using an existing project, this is a good choice to get the most features and fewest bugs.
However, if you are working with a team, all members must install the same version of Unity. Communicate with them to pick a version. If they have already created their project, you can either install the version manually through the Download Archive or try to add the existing project to Unity, after which it will prompt you to install the correct version.
Downloading an editor will prompt you to add certain modules. These modules are divided into Dev Tools (editor), Platforms (for exporting your game), Language packs, and Documentation. Generally, you don’t need to install any modules and can do so later. However, if you do want to use Visual Studio, you can do so here.
If you are new to programming, you might think programming is mainly typing a bunch of characters into source code.
However, this would be incredibly slow, and programming also includes understanding existing code, modifying (refactoring) code, and detecting errors. Modern editors tailor to this workflow by providing useful tools to do these things, as well as providing features to write code faster.
Some of these tools are listed below, but language servers are the most important tool ever for writing code. Writing code without a language server is annoying and punishing, and is a very poor use of time. Language servers make writing code fun and much less error-prone. Do not write code without a language server unless you want or already hate programming and yourself.
AI coding assistants are also very useful, mainly to avoid reading documentation or researching algorithms. However, if you are new to coding, I would avoid relying on these too heavily, as reading documentation and manually implementing algorithms are both valuable skills.
Snippets are the simplest way to write code faster. They are a smart “copy-and-paste” tool for commonly used sections of code. For example, a for-loop can be a snippet, where the editor will generate a template for the for loop, and you simply fill in the values. A Unity message (like Start) can also be a snippet. You can even make your own snippets quite easily.
Syntax highlighting allows the editor to understand the syntax of the programming language you are using, and then color-code different types of things in the language. For example, keywords (like for
, while
) might be in one color while variables are in another.
Syntax support can also be a little smarter than just highlighting, including folding code sections and even jumping to definitions, but this is often delegated to the LSP. Syntax support is built into VSCode, and comes with a language server.
The Language Server Protocol (LSP) is the de facto standard for adding adding language support to an editor, and is often synonymous with language support. Language support just means giving the editor the knowledge to understand what code means, and to do things with it.
You can see all potential capabilities on the LSP on the specification, but some very cool features that I use all the time include:
A debugger allows you to inspect a program while it is running in order to catch errors. They allow you to pause the code to control execution when certain conditions happen (when a line of code is reached, when a variable is a certain value, when an exception happens) and then inspect the code during that state (current variables, current function call stack, etc). They are very powerful in determining why a runtime error is happening, but not exactly for fixing it. In Unity specifically, debugging is relatively heavy-weight and can slow down performance immensely, but can be useful nonetheless.
AI coding assistants, like GitHub Copilot, are pretty common nowadays when writing code. They can be useful in
VSCode is one of the 3 major code editors that people use with Unity. The other 2 being Jetbrains Rider (cross platform) and Visual Studio (Windows only). Rider and Visual Studio are more heavy-weight, full IDE experiences, while VSCode is primarily a text editor with custom extensions to suit your needs. This makes VSCode a little harder to set up, but much quicker to start up.
Visual Studio and JetBrains Rider are also good a popular choice for IDEs.
Visual Studio is well integrated with Microsoft’s MSBuild (if you have ever seen a .vcxproj file), which makes building projects in many languages “just work” on Windows. It also has all language features built in. In addition, it has very good support for all .NET and C++ applications on Windows.
Rider is a free cross-platform JetBrains IDE, and alongside all the features the Visual Studio has, it contains a lot of smart features that help you write the clean, optimized code. It lets you configure a “recommended coding style” that keeps your not only your syntax clean, but also ensures correct naming conventions. It also tells you when an operation is not efficient, or when there is a better way to write a certain section of code, leaving you with very clean code. Rider also supports other .NET and game dev frameworks.
Feature | Visual Studio | JetBrains Rider | Visual Studio Code |
---|---|---|---|
Syntax highlighting | ✔️ | ✔️ | ✔️ |
Language Server | ✔️ | ✔️ | Extension |
Building | ✔️ | ✔️ | Extension |
Debugging | ✔️ | ✔️ | Extension |
Lightweight | ❌ | ❌ | ✔️ |
Extensions | Some | Some | Many |
Other uses | .NET/C++/A lot | Godot, Unreal | Everything |
Installing VSCode is relatively simple. You can do so from their website, or via your package manager of choice.
You can open the C# project in a few ways:
If this opens in the wrong editor, you can change it by going to Edit → Preferences → External Tools
By default, all you get in VSCode is syntax highlighting, which shows basic keywords and syntactic information via color. To get anything else, you need to install some extensions.
Extensions are installed via the Extensions tab on the left.
The Unity extension, which will also install the C#/C# Dev Kit extensions and the .NET Install Tool, installs language and debugging support for C# and Unity. The C# extension provides language server support.
Note that this process may differ depending on your operating system. This section is only tested on Windows and Ubuntu, and we will update this for Mac as soon as we get our hands on one.
The language server integration is already set up in VSCode, but the language server itself is likely not installed, as indicated by this error message:
.NET is required to run the language server, so you must install .NET. To do so via the .NET Install Tool, which is installed with the Unity extension, you can open the command palette (View → Command Palette, Ctrl+Shift+P, or Command+Shift+P), and run .NET Install Tool: Install the .NET SDK System-Wide.
Use the default value for the version, and then follow the installation instructions.
Once this finished installing, you will have (basic) language server support! At this point, you should be able to do LSP operations like renaming symbols in one file.
However, your project is likely not correctly loaded into VSCode (as evidenced by this red X in the bottom left), since the project loads when you open VSCode. Thus, VSCode does not know about Unity.
To fix this, you must reopen VSCode by closing it and reopening the C# project in Unity. After this, you should get full language support! To know if it worked, try to access a MonoBehaviour field like transform
, and it should show autocomplete for it.
Now that you’ve installed a language server, you can start coding with sanity!