How to Create and Use Sorting Layers in Unity

Notes:

How to Create and Use Sorting Layers in Unity :

Sorting Layers:
Sorting Layers are used to control the overlay order or order of visibility of 2D images, which are also called as sprites.

We can control which sprite should be rendered on top of which sprite with help of sorting layers.
By default 2D sprites are placed in default layer. When we drag sprites in to scene view they are rendered from back to front.

Assigning sorting layers:
Select a game object
- Click on the Sorting Layer drop down menu in Sprite render component
- Click on the appropriate sorting layer name

Note:
Sprites are rendered based on the order of layers in sorting layers list
Top to down layers indicated back to front rendering

Order in Layer:
- control the overlay order or order of visibility of 2D sprites in specific layer
- Order in Layer property is used to solve z fighting issue of sprites in the same layer
- higher value sprites are rendered in front of lower value sprites