Tips and Tricks, Useful Links
Proper Installation: Unity Hub and VS Code
Over the years, there have been different "best practices" on how to set up Unity.
Currently, it begins with installing Unity Hub, for which you need to first get a free account on unity.com. The Hub can be downloaded from https://unity.com/download, and it will allow you to install different versions of Unity, and manage your projects.
Once you have the Hub installed, you can install the latest version of the Unity Editor — it will be highlighted as the "Recommended Version":
During installation, it will try to also install Visual Studio. While it will work, that program is quite bulky, slow, and might even require more accounts and logins. Instead, we recommend using Visual Studio Code (VS Code), which is a much lighter version of the same program, and which is also free.
Make sure to Deselect Visual Studio during the installation of Unity:
It has a website dedicated to setting up VS Code to work perfectly with Unity, which you can find here: https://code.visualstudio.com/docs/other/unity
Make sure to follow all instructions listed there, and you should be good to go.
In the end you should have the proper Extensions installed in VS Code, and it should be set up as Unity's default. If everything has been done correctly, the features listed under Editing Evolved on the website should work for you, which is the whole point of using a complex Integrated Development Environment (IDE) like VS Code in the first place.
Does it actually all work?
Please make sure that it actually works correctly! You can save yourself a lot of trouble if everything works as intended. It helps you find errors, helps you write code, and so on.
Code Formatting
When writing code, it is important to keep it readable. This means that you should use indentation to show which parts of your code belong together. This makes it easier to see what your code is doing, and it makes it easier to find and fix any problems that might occur.
Fortunately, VS Code can do this for you automatically. You can set it up to automatically format your code whenever you save it, by going to File > Preferences > Settings (or hitting Command + , on macOS) and then searching for "format on save". You can then check the box to enable it.
Github Copilot
To taste the future, you can try to get access to Github Copilot through their education program: https://education.github.com/discount_requests/application.
Once you have an account and a license for the Copilot, you can integrate it into VS Code by following the instructions here: https://code.visualstudio.com/docs/editor/github-copilot.
Now you can radically increase the speed at which you develop code: it not only is very good at completing code and fixing errors, it can in fact write whole segments based on just a small comment! Try it out by writing a comment like // Create a new cube and set its color to magenta
and then pressing the Tab button to validate the suggestion.
Iterative Development
When developing any software, it is important to follow an iterative development process. This means that you should start with the basics, and then add more and more features to your project. This allows you to test each feature as you add it, and make sure that it works before you add more features. It also allows you to test your project at any point, and see how it works so far. The smaller the steps you take, the easier it is to find and fix any problems that might occur.
Debug Output
When developing software, it is important to be able to see what is happening in your program. This is called debug output, and it can be used to see what your program is doing at any point. In Unity, you can use the Debug.Log()
function to print out messages to the Console window. This is very useful for testing your program, and finding any problems that might occur.
As any good Development Environment, Unity can directly integrate with VS Code. One of the most useful aspects of this here is that it links the console output from Unity directly to VS Code, so you can see the output of your Debug.Log()
calls directly in the editor.
If you see an error, a warning, or just a message that you want to know more about, you can double-click on it in the console, and it will take you to the line in your code that caused the message to be printed out. This is very useful for finding and fixing problems in your code.
Sharing and Collaboration
In all of software development, the most common way to share code is through version control. This is a system that keeps track of all the changes you make to your code, and allows you to share it with others. It also allows you to go back to previous versions of your code, in case you want to undo some changes you made.
The most popular version control system is called Git, and it is used by most software developers. It is also the system that is used by GitHub, a website that allows you to share your code with others. You can create a free account on GitHub, and then create a repository for your project. A repository is a folder that contains all the files for your project, and it is linked to a GitHub account. You can then push your code to the repository, and it will be stored on GitHub. You can also pull code from the repository, which means you download the latest version of the code from GitHub.
There are many more features to Git and GitHub, but these are the most important ones.
An easy way to use this system is through Github Desktop, which is a program that allows you to manage your repositories. You can download it from Github.com.
A good tutorial on how to set it up specifically for Unity projects can be found here: https://blog.terresquall.com/2020/04/using-github-desktop-as-your-source-control-repository-in-unity/