Unity GameObject Z-Axis

875 views Asked by At

I would like to put the red dot before the numbers. I can do this by changing Z coordinates. But then the white area gets also located behind the red circle.

What am I doing wrong? Thanks a lot.

enter image description here

1

There are 1 answers

1
Felipe Jun On

Inside a canvas, if no override of sorting is taking effect the render sorting follows the sibling index in the hierarchy.

So if you want to order the objects like:

spectator -> white square -> red dot -> numbers

Just order them like this:

  • Canvas
    • ...
    • 000
    • red dot
    • white area

You can see that children that are lower in the hierarchy are rendered last ("closer" to the viewer).

This is true if all the children are UI elements, it won't work like this if mesh and sprite renderers are mixed with UI elements.

If it is the case, and if it is desired to be like this, I recommend you to read about sorting layers and overriding sorting layers of canvases.

Sorting Layer

Overriding Canvas sorting