Get Your Personalized Game Dev Plan Tailored tips, tools, and next steps - just for you.

How to Use Sorting Layers in Unity

Posted by Gemma Ellison
./
August 31, 2023
The cover for How to Use Sorting Layers in Unity

I wanted to learn more about how Sorting Layers work in Unity. I make assets for 3D projects, so I was unfamiliar with Unity’s 2D Pipeline.

I spent a few hours researching the Sorting Layers system. Then, I put together this comprehensive guide to Sorting Layers. I designed this guide for beginner game developers with Unity. But, you can still learn something new if you are an intermediate or advanced game developer.

This article is the most comprehensive summary of the Sorting Layers system. It is the most complete explanation of how Sorting Layers relate to the tags and layers system.

I hope you find it valuable!

Key Takeaways

  • Sorting Layers are a rendering option in the 2D Pipeline.
  • To make Unity render an object on top, give that renderer a higher-priority Sorting Layer.
  • Unity renders layers at the bottom of the list in front of layers at the top.
  • To set the Sorting Layers for your project, open Edit > Project Settings > Tags and Layers.
  • To set the Sorting Layer for a specific Renderer, open it in the Inspector.

With the high-level overview done, let’s get into the details.

This is a series on Unity Physics. We recommend reading the series in order.

  1. Unity Physics
  2. Unity Collision Detection
  3. Character Controller and Input Systems
  4. Rigidbody Mass in Unity
  5. How to add Friction to a Rigidbody
  6. Cylinder Collider in Unity
  7. Box Collider in Unity
  8. Box Cast in Unity
  9. Sorting Layers
  10. Get the distance between two objects
  11. How to normalize a vector

What are Sorting Layers?

The Sorting Layer is a rendering option in Unity. When you assign an object to a Sorting Layer, you tell Unity when it should render that object.

Why does rendering order matter?

The rendering order sets which objects Unity will render on top of others. Think of it like painting. You start with a blank canvas. Then, you apply some brush strokes. Then, you paint on top of those brush strokes. This technique is how rendering works, too.

Do I need to use Sorting Layers?

No. Unity has an entire sorting pipeline. You don’t need to use Sorting Layers. You should build your project and allow Unity to handle sorting based on camera distance. Then, you can override the sorting layer if you need something special.

Where can I find the Sorting Layers?

You can set the Sorting Layer for a specific Renderer in the Inspector.

In the 2D Pipeline, most renderers expose the Sorting Layer option.

In the 3D Pipeline, most renderers don’t show this option.

Create a free account, or log in.

Gain access to free articles, game development tools, and game assets.