mirror of
https://github.com/galacean/engine.git
synced 2026-06-24 15:27:44 +08:00
2.0 KiB
2.0 KiB
order, title, type, label
| order | title | type | label |
|---|---|---|---|
| 6 | Rendering Order | UI | UI |
The rendering order of UI components follows two rules:
- Different
UICanvasinstances follow a specific rendering order based on theirRendererModetype. UIRenderercomponents under aUICanvasare rendered according to a depth-first order, from parent to child, and from left to right.
UICanvas
Assume the current runtime:
- There is a scene
Scene - The scene
Scenecontains two cameras,Camera1andCamera2 - The scene
Scenecontains three canvases:Canvas1withWorldSpacerender modeCanvas2withScreenSpace-Overlayrender modeCanvas3withScreenSpace-Camerarender mode, usingCamera1as the render camera
journey
title Scene Rendering Cycle
section Camera1.render
Canvas1.render: 5
Canvas3.render: 5
section Camera2.render
Canvas1.render: 5
section Ending
Canvas2.render: 5
It's important to note:
- Canvases with
ScreenSpace-Camerarender mode will only render with their corresponding camera, and they follow the general camera clipping rules, just like canvases withScreenSpace-Overlayrender mode. - Canvases with
ScreenSpace-Overlayrender mode can still be rendered without a camera. - Within the same camera, the rendering order of
UICanvasfollows these rules: canvases in the overlay mode have their rendering order determined only bysortOrder.
flowchart TD
A[Sort rendering data] --> B{canvas.sortOrder}
B -->|Not equal| C[Return comparison result]
B -->|Equal| D{Canvas and camera distance}
D -->|Not equal| E[Return comparison result]
D -->|Equal| F[Return comparison result]
UIRenderer Rendering Order
stateDiagram
RootCanvas --> A
RootCanvas --> F
A --> B
A --> E
B --> C
B --> D
As shown in the diagram above, the rendering order under the root canvas follows A -> B -> C -> D -> E -> F. It is important to note that setting UIRenderer.priority does not change its rendering order.