Unity provides different types of UI options for building a game world UI, allowing users to create a UI that fits your application needs exactly. There are two main types of UI categories: Screen Space and Space. In this tutorial you will learn how to create a space user interface.
Create a game world UI
Unity provides different types of UI options for creating a game world UI, allowing you to create a UI that suits your needs. There are two main user interface categories: screen space and game world. Screen Space projects the user interface onto the viewer's screen and is what most people think of when they talk about the user interface. The UI of this game world places the UI directly in the scene environment so that it exists in 3D space. XR applications often use this type of user interface because it makes the experience feel more natural.
Creating a game world UI or user interface in Unity starts with creating a canvas. The Canvas object defines what is and isn't part of the UI system and governs how the UI is rendered on the screen.
1. Right-click in the hierarchy and select User Interface> Canvas. The canvas may not be immediately visible because it is extremely large compared to the scene.
2. Find the canvas component in the inspector and change the render mode to World Space.
3. When this user interface receives input (e.g. has a button to press), drag the main camera into the event camera slot.
The canvas rendering mode is set to space and the event camera is connected to the main camera so it can interact with the user interface.
The canvas can now be moved freely in the scene, but it is still extremely large. The easiest way to scale the canvas to an appropriate size is to group it under an object that is already in the scene and reset the canvas.
4. In the hierarchy window select Canvas and assign it to an object in the scene.
5. Select the canvas and click in the inspector window on the gear wheel in the upper right corner of the menu or the three dots and select Reset
6. Pull the canvas away from the subordination under the object and place it outside the object in the hierarchy window.
7. Go ahead and select the scaling option for the canvas. Scale it until it appears in the position in the world where you want it to be.
The space canvas is adjusted with the rest of the surrounding objects.
Learn more about creating a game world UI at Unity
Originally posted on 2020-03-14 14:33:38.