Search Unity

How to bring a UI element to the forefront without changing its position in the hierarchy of objects

Discussion in 'UGUI & TextMesh Pro' started by SERG__ZV, Oct 14, 2019.

  1. SERG__ZV

    SERG__ZV

    Joined:
    May 19, 2016
    Posts:
    8
    Hello experts. There is a question.
    Everywhere it is written, to bring some kind of UNITY UI element to the foreground, you need to lower it lower in the hierarchy. But I have such a task.

    I make a scrolling group of buttons via scrollContent, the number of which is not known in advance.
    Each button represents the player, or rather his settings.
    Now I'm trying to implement a player settings button by clicking on which a window will open under it in which his settings will be.

    But the problem is that a hidden child object that is the settings window of this player when opened is blocked by the lower buttons of other players, which should not be.
    And also in the fact that ScrollContent Distributes the queue of buttons in their order in the hierarchy

    Previously (as can be seen in the screenshot below), I tried to use a drop-down list instead of a button. It was redone for a long time under the drop-down menu from one line in which there are many elements, he had no problems with overlapping. However, I need to add another drop-down list to the player’s settings window. And in unity, the attachment of a drop-down list to the drop-down list is not provided :)

    Well, I thought if the developers using the drop-down list functionality somehow circumvented their rule - that the lower element in the hierarchy overlaps the upper one. An ordinary user can technically do this using his own more suitable element for this.

    I suspect that perhaps there is some kind of component for this, but I did not find it.

     
  2. SERG__ZV

    SERG__ZV

    Joined:
    May 19, 2016
    Posts:
    8
    Found! In general, they use the Canvas component for this. We click on the checkbox Override Sorting (to rewrite the sort order of objects) and set it to which layer we would like to bring it to. They just put a layer number 30000 there just in case :)
     
    bettywhite and nkeep like this.
  3. SERG__ZV

    SERG__ZV

    Joined:
    May 19, 2016
    Posts:
    8
    But for some reason, when I press it, the lower button is pressed through it (
     
  4. SERG__ZV

    SERG__ZV

    Joined:
    May 19, 2016
    Posts:
    8
    Found again! For physical clicks, the Graphicraycaster component is responsible))
     
    bettywhite likes this.
  5. bettywhite

    bettywhite

    Joined:
    Oct 22, 2019
    Posts:
    14
    Cheers brother!