Canvas for Unity game development UI

Canvas

Canvas Component is an abstract space for UI layout and rendering. All UI must be under this element (child object). Simply put, Canvas is the component that renders UI

 

Render Mode

There are three ways of UI rendering:

  • Screen Space – Overlay: screen space – overlay

  • Screen Space – Camera: Screen Space – Camera

  • World Space: world coordinate space


Screen Space – Overlay

Screen Space - Overlay

In this mode, the Camera will not be referenced, and the UI will be displayed directly on top of any graphics

1.Pixel Perfect: It can make the image clearer, but there is additional performance overhead. If there are a lot of UI animations, the animation may not be smooth

2.Sort Order: Depth value, the higher the value, the more front the display

 

Screen Space – Camera

Screen Space - Camera

Use a Camera as a reference, and place the UI plane at a certain distance in front of the Camera. Because it is a reference to the Camera, the UI plane will be automatically resized when the screen size, resolution, and Camera viewing cone change. If the object (GameObject) in the Scene is closer to the camera than the UI plane, it will block the UI plane.

1.Render Camera: The camera used for rendering

2.Plane Distance: the distance from the Camera

3.Sorting Layer: The sorting layer that Canvas belongs to, add it in Edit->Project Setting->Tags and Layers->Sorting Layers, the lower the layer is displayed , the front

4.Order in Layer: The order under the sorting layer that Canvas belongs to, the higher the value, the more front the display

 

World Space

World Space

Treat the object as a plane (GameObject) in the world coordinates, that is, as a 3D object, and display a 3D UI

1.Event Camera: The camera that handles UI events (Click, Drag), the set Camera can trigger the event

Reprinted from: http://k79k06k02k.com/blog/190/unity/unity-ugui-%E5%8E%9F%E7%90%86%E7%AF%87-%E4%B8%80%EF%BC %9Acanvas

Guess you like

Origin blog.csdn.net/jxfcwys/article/details/72866310