Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

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,255
    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:
    419
    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,255
    You mean having a canvas as a parent of a2, bc2, c2, like:
    • A
      • a1
      • canvas
        • a2
    ?