How do I sort the child GameObjects of two sorting groups

When the dog is bathing, I want it to stay on the tub top forever I can only set it as a child gameobject of the bath tub (I can’t just set dog sorting which would cause it to end up on other items as well)

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

In short,

  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.

Additional reading in the official docs:

And SortingGroups can also be extremely helpful in certain circumstances:

You may consider switching to using actual z-depth for your 2D projects. There are a lot of advantages for doing it, even if using an orthogonal camera. Stuff like this just “comes naturally” when you leverage the 3D world.

    • Thank you for your reply and Z POS has solved my problem
1 Like