Skip to content

Custom Sort Axis

In 2D games we generally want to sort sprites along the Y axis. So we want to have objects that are below to render on top of the ones that are higher up.
This can be achieved by playing around with the Sprite Renderer Order in Layer values, but we can also configure Unity to sort sprites and objects along the Y axis automatically if we want to:

Project Settings, Graphics: Transparency Sort Mode set to Custom Axis and Transparency Sort Axis set to Y 1, both marked in red

If you are using URP you can change this option in the Pipeline Renderer asset (if you set the sorting axis to the Z axis sprites will get sorted by depth, this is used in 2.5D and 3D games):

The AllIn12DRenderer asset in the Inspector, with Transparency Sort Mode set to Custom Axis and the sort axis set to Z 1