Sorting in UI based on hirearchy

Avatar
  • updated
  • Answered

Hi,

Is it possible to get shapes to sort the same as other UI primitives (Image for example) which is based on the order in the hierarchy?


I've tried a number of different settings and sorting layers but I'm either getting the problem that they're not showing up, or that they appear on top of an overlay that is further down the hierarchy and goes over everything else that isn't from shapes.  This is with a screen space camera canvas if that makes any difference.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Answered

this is unfortunately one of those things that are surprisingly complicated outside of Unity's UI system - it's very hard to inject things in the middle of it

Unity's UI can easily change draw order because all Unity UI is essentially combined into a single mesh where everything is sorted by triangle order

so since UI is a single mesh, shapes will either be fully in front or fully behind it, and making a separate system for overriding draw order will also break instancing, so, for things like this I recommend making two UI canvases, one for all UI on top of Shapes, and another for all UI underneath

Avatar
Freya Holmér creator
  • Answer
  • Answered

this is unfortunately one of those things that are surprisingly complicated outside of Unity's UI system - it's very hard to inject things in the middle of it

Unity's UI can easily change draw order because all Unity UI is essentially combined into a single mesh where everything is sorted by triangle order

so since UI is a single mesh, shapes will either be fully in front or fully behind it, and making a separate system for overriding draw order will also break instancing, so, for things like this I recommend making two UI canvases, one for all UI on top of Shapes, and another for all UI underneath