Understanding the Canvas and RectTransform
We are only going to focus on the in-game UI to communicate different information to the player using the Unity GUI system (or uGUI). At the time of writing, a new GUI system called UI Toolkit has been released. Even though we will introduce UI Toolkit, remember that uGUI isn’t going anywhere anytime soon. It’s crucial to grasp both to be versatile in your UI design approach. We will explore UI Toolkit in the next chapter.
If you are going to work with Unity UI, you first need to understand its two main concepts—the Canvas and RectTransform. The Canvas is the master object that will contain and render our UI, and RectTransform is the feature in charge of positioning and adapting each UI element on our screen.
In this section, we will be:
- Creating a UI with the Canvas
- Positioning elements with RectTransform
Let’s start by using the Canvas component to create our UI.