Three rendering modes of Unity3D Canvas Screen Space - overlay, Screen Space - camera, World Space

Canvas has three rendering modes (render mode): Screen Space - overlay (overlay), Screen Space - camera (camera), World Space (world)

  • Screen Space - overlay

Overlay mode , this mode is generally used more, it is always at the front of the 3D scene, and will block the objects in the 3D scene (if there is a UI in the corresponding position). In the usual rendering pipeline, the objects in the scene are usually drawn first, and the UI is drawn last, so the UI in this mode will block the rendered picture in the 3D scene.

insert image description here

  • Screen Space - camera

Camera mode , this mode needs to be used together with a camera (assuming the camera name is UICamera), the UI is located in front of UICamera, and the distance from the camera can be set through the Plane Distance on the Inspector panel, the UI in this mode will be affected The influence of UICamera settings, such as the UICamera setting mode is perspective mode (Perspective), then the rendered UI will also have the effect of far smaller and near larger.

insert image description here

  • World Space

World space , this mode is easier to understand. You can directly treat the corresponding UI object as a 3D object, which will be blocked by other 3D objects positioned in front of it, and will also block 3D objects positioned behind it.

insert image description here


Screen Space - overlay and Screen Space - camera rendering sequence:

Conclusion : Screen Space - camera is a structure that is rendered in the scene. Its rendering sequence is after the regular 3D objects, but before the rendering of the Screen Space - overlay Canvas, the verification method is as follows. The first picture is for the UI The structure has two canvases, the render mode of one is Screen Space - overlay, and the render mode of the other is Screen Space - camera.

canvas1 , render mode 是 Screen Space - camera

insert image description here

canvas2 , render mode 是 Screen Space -overlay

Then the analysis screenshot of frame debuger

insert image description here

Analysis screenshot of frame debuger

Therefore, it is verified that the UI rendering time of the Screen Space - camera mode is before the UI of the Screen Space - overlay mode, so the UI of the Screen Space - overlay mode will not only cover the 3D objects in the scene, but also block the Screen Space - camera The UI of the modal (if there is an overlap). Of course, we can also measure the rendering order of the World Space UI in the same way. Here is a brief conclusion, including 3D scenes, Screen Space - overlay, Screen Space - camera, and World Space. The order of rendering is: 3D scene - > World Space -> Screen Space - camera -> Screen Space - overlay, the screenshot is as follows: The above is the


insert image description here


introduction of all three rendering modes of Unity3D Canvas .

Guess you like

Origin blog.csdn.net/qq_41841073/article/details/126607918