Search Unity

Question force z-index on UI element without hierarchy changes?

Discussion in 'UGUI & TextMesh Pro' started by Tom163, Oct 17, 2022.

  1. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Is there any way to FORCE the z-index on a UI element without messing with the hierarchy?

    I have a small tree of elements like this:
    • A
      • a1
      • a2
    • B
      • b1
      • b2
    • C
      • c1
      • c2
    I I need to make sure that elements a2, b2 and c2 are always on top of everything else (tooltips). Because this whole thing is dynamically placed (player cursor position), I need to keep the hierarchy intact.
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    It should be possible to override the default hierachy based order for some elements by creating a nested canvas and setting either sorting layer or order in layer for that nested canvas.
     
    Tom163 likes this.
  3. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    You mean having a canvas as a parent of a2, bc2, c2, like:
    • A
      • a1
      • canvas
        • a2
    ?