How do I reorder the Sorting Layers through code?

Is it possible to reorder the sorting layers in Unity? Not for any particular sprite renderer, just the sorting layers in general?

I looked under the struct SortingLayer, but SortingLayer.Layers is get only…

If this isn’t possible, well boo-hoo, I’ll find a way to make things work :sweat_smile:

My specific circumstance:
Specifically, I have a certain santa clause who sometimes is above ground appearing behind snow, but sometimes below ground appearing in front of buildings. I was considering having the buildings disappear, but that’s a lot of sprite renderers to set them all manually to a new layer, and things would just be more organized if I could re-arrange the sorting layers.

Why not just have a sorting layer in front and one in back, then move Santa between them by changing the SpriteRenderer’s setting?

I hear that Santa enjoys changing sorting layers because it keeps his reindeer on their toes.

1 Like

So is re-arranging sorting layers not a feature? But thanks for your suggestion, I’ll do that for now!

It looks like you can move them… grab them by those horizontal tick marks at left edge, like any other list / array in Unity… are you not able to drag them? I can… Unity2018 and Unity6, same-same…


Yes I can drag them :sweat_smile:

I meant at runtime (through code), but I’ve solved my problem, so no need to reply to this thread anymore!