Sorting layers doesnt work

Sorting layers doesn work for my object, it appears on top of everyhting except UI.


Im using 2 cameras i tried depth, still doesnt help

Does not work in what way? This SpriteRender belongs to the ‘Default’ sorting layer, whereas the position (i.e. layering) of sorting layers is assigned elsewhere. Out of curiosity, is one supposed to use negative integers for ‘Order in Layer’?

Yes you can use negatives

OK. You can edit layers, perhaps that is what you need explore. It should allow you layer sorting, too.

Look for the 'Layers' button in the top right end of the editor.

I tried this it doesn work

Im using 2 cameras i tried depth, still doesnt help

If regarding layering everything works well per layering settings, then it must be something else.

If you are using multiple cameras, then that’s likely the cause. Either their order in Hierarchy, the layers assigned to them, what they are rendering, something. It’s difficult to say without seeing more. You may also need to inspect in detail what your ‘Parallax BG’ script is doing.

Three (3) primary ways that Unity draws / stacks / sorts / layers / overlays stuff:

In short, as far as the Standard Rendering Pipeline,

  1. The default 3D Renderers draw stuff according to Z depth - distance from camera.

  2. SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties

  3. UI Canvas Renderers draw in linear transform sequence, like a stack of papers

If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:

  • identify what you are using
  • search online for the combination of things you are doing and how to to achieve what you want.

There may be more than one solution to try.

For instance, you may even use multiple co-located cameras (along with different Layers and LayerMasks drawn to different-depth Cameras) to more-explicitly control apparent draw ordering.

Additional reading in the official docs:

And SortingGroups can also be extremely helpful in certain circumstances:

Other rendering pipelines may have other ways of layering (HDRP and URP). Go see the latest docs for details.

There’s lots of third party open source packages available as well, such as this:

one camera will always render on top of the other, you cannot sort specific objects diffrently between cameras