Canvas/Panel Issue (Zindex, Layer order and canvas draw)

HI there.
I’m currently comppletely lost with this new unity UI system, i’m making a little game with have a lot of different UI (for instance i have a stats panel, a skills panel with drag and drop, the basic UI for the ennemy life bar, experience, levels and so) And i can’t understand how Unity define the “UI Z index”.

I mean for 3d elements its simple, its about the Z Index who define who is render over what.
The layers order also help for place like Particules systems on top of 3d components.

But the Canvas/Panels have there own weird “Z Index” i can’t understand. Sometimes my sprites are render behind the UI (even if in my scene they are in the front).
When i drag and drop a UI Skills in another UI Panel Bar, sometimes its draw in front of this bar, sometime behind… Even if the hierarchy order is supposed to bee good, the Z Index too.


As you can see in the screen below, my tooltip is supposed to be Over the Skills and Skills Menu, which is true the first time i click on a skill, but when i drag and drop or move a skill, the tooltip is draw “under” my skills menus… I can’t understand why, its just moving the location of the Tooltip coordinate to the right skill, nothing else, (and with a Z index superior, but z index change nothing)

Nothing change if i switch the canvas. If i click on another lower skills the tooltip is completely under the menu. Is there some magic to order Canvas and panels ? (since layer order, z index and hierarchy order seems to do nothing…)

Thanks a lot and sorry for my poor english^^.

Sorting of UI happens at different levels:

  • Render Order / Z order (Screen Space - Camera / World Space only)
  • Hierarchy Order / Sprite sorting layer (exactly like the 2D system)
  • Sprite Layer order (exactly like the 2D system)

Screen Space Overlay is almost exactly like the Legacy GUI, in that it renders on top of everything, UI elements are then drawn using the Hierarchy / 2D Rendering system on the camvas.

For World Space and Screen Space Camera, the camera render order and Z order are taking in to account as well.

Hope this helps.

Has something changed about this? Heres some healthbars on a world space canvas, they are still sorted by their hierarchy order. No changing of transparency sorting settings fixes this. Moving the closest healthbar to the bottom of hierarchy makes it render on top of other healthbars, like it should. Is there no “sort by z” option for canvases? Do i really have to sort the hierarchy myself??? Or creating a canvas per healthbar is the recommended workflow? Doesnt that mean its gonna create a batch per canvas then, which is terrible?

7491416--922262--upload_2021-9-13_14-10-1.png

7491416--922265--upload_2021-9-13_14-10-31.png

Putting a canvas with Override Sorting enabled on the element parent solves the issue. And it doesnt create a batch per element. Although sometimes it still splits the batch into multiple (2 or 3 usually, in my case), its not too problematic. Still would like Unity to introduce ParticleSystem-like sorting mode option for canvases.

7491592--922304--upload_2021-9-13_15-24-32.png