2D rendering order
Learn about the criteria Unity uses to decide whether one 2D GameObject renders in front of another.
読み終わるまでの所要時間 2 分最終更新 1ヶ月前
To determine whether a 2D object renders in front of another, Unity uses the following criteria. If Unity renders a GameObject before another, the first GameObject appears behind the other.
The following applies to sprites, tiles, and sprite shapes.
-
Sorting layer: Unity renders a GameObject earlier if its Sorting Layer is higher in the list in the Tags and Layers window. For more information, refer to Arrange 2D GameObjects in layers.
-
Sublayer: Unity renders a GameObject earlier if its Order in Layer property has a lower value. For more information, refer to Arrange 2D GameObjects in layers.
-
Render pass order: Unity renders a GameObject earlier if the Render Queue property of its material is lower. For more information, refer to Set the order within a layer and sublayer.
-
Distance: Unity renders a GameObject earlier if it's further from the camera. The distance calculation depends on the Projection property of the camera, the Transparency Sort Mode property, and the Sort Point if the GameObject is a sprite. For more information, refer to Set the order within a layer and sublayer.
-
Shader and material properties: Unity renders GameObjects with the same shader and material properties together in a group. The order Unity uses to render the different groups isn't guaranteed.
If all the previous values are the same for two GameObjects, Unity has an internal render queue order that determines which GameObject renders first. This order isn't guaranteed and you can't control it.
The order can be different depending on your project.