Version: Unity 6.4 (6000.4)
Language : English
Sorting sprites
Change the sorting order of 2D GameObjects

2D rendering order

To determine whether a 2D objectA 2D GameObject such as a tilemap or sprite. More info
See in Glossary
renders in front of another, Unity uses the following criteria. If Unity renders a GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
before another, the first GameObject appears behind the other.

The following applies to spritesA 2D graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development. More info
See in Glossary
, tiles, and sprite shapes.

  1. 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.

  2. 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.

  3. 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.

  4. Distance: Unity renders a GameObject earlier if it’s further from the cameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
    See in Glossary
    . 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.

    Note: By default, all sprites are on the same Default sorting layer, have the same Order in Layer value, and have the same Render Queue value. If you don’t change these settings, Unity uses the distance to camera as the first differentiator for sorting.

  5. ShaderA program that runs on the GPU. More info
    See in Glossary
    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.

Note: If you add a set of GameObjects to a Sorting Group component, the group renders as one unit on a single sorting layer and sublayer. You can still sort the GameObjects inside the group. Use Sorting Groups to avoid instances of prefabsAn asset type that allows you to store a GameObject complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. More info
See in Glossary
mixing with each other. For more information, refer to Prevent 2D GameObjects mixing in sorting layers.

Additional resources

Sorting sprites
Change the sorting order of 2D GameObjects