Introduction to the UI Canvas
Learn about the UI Canvas and how it positions UI elements in your scene.
阅读时间2 分钟最后更新于 2 天前
Before you can add buttons, images, or interactive menus to your application, you need a foundational layout. The UI Canvas acts as the root container for all 2D user interfaces in Unity Studio, and ensures your dashboards, overlays, and configuration panels render correctly on screen.
Supported UI elements
Think of the UI Canvas as a blank sheet where you can place your buttons, text, images, and other controls. Every UI element must belong to a UI Canvas.
When you add a UI element to your scene, the element becomes a child of the UI Canvas in the Hierarchy panel. The UI Canvas controls how the UI element is positioned and scaled in the scene, and how it responds to different screen sizes.
For a list of all the UI elements you can add to a UI Canvas, refer to UI Elements available in Unity Studio.
UI element transforms
Each UI element on the canvas uses a UI Transform component instead of the regular Transform component. A UI Transform is a rectangular transform designed for 2D elements.
The UI Transform enables you to move, resize, and rotate UI elements. You can do this directly in the Scene view or enter specific values in the Inspector.
To edit the properties of the UI Transform, select the UI element in the Hierarchy panel and view its properties in the Inspector panel.
Multiple canvases
You can create multiple canvases in one project to show different UI layouts at different times. For example, you can create a canvas for your main user interface and a different canvas for contextual menus that only appear when the user interacts with certain objects in the scene.
Each canvas contains a Canvas component that controls what order the canvas renders in relation to other canvases.
To add a new canvas, refer to Create a UI Canvas.
2D support
Currently, you can only create 2D UI canvases in Unity Studio. 3D canvases aren't supported.