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. Dismiss Notice

Question Bring an element to front

Discussion in 'UI Toolkit' started by Roshinator, Sep 20, 2020.

  1. Roshinator

    Roshinator

    Joined:
    Feb 2, 2019
    Posts:
    13
    I have an element that acts like a universally invokable dialog box that is set to dontDestroyOnLoad. How do you bring the element to the front of all UI since setting the z-align in the stylesheet did nothing?
     
  2. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    366
    In the panelSettings of a UIDocument you can set the sort order of it.
    Put only the Dialog in one and set the sort order to a higher value then the other UIDocuments have.
     
  3. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    If you don't need more than one panel (for example, because of difference in scaling or rendering to texture), we highly suggest you don't have more than one PanelSettings (each PanelSettings will generate one separate panel). Instead, you can either keep your dialog box in front of everything (by having it as the last sibling) and flipping its display to "Flex" (show) and "None" (hide), or moving it to the last sibling position when you want it to show and moving it back up on the hierarchy to hide it.
     
  4. Roshinator

    Roshinator

    Joined:
    Feb 2, 2019
    Posts:
    13
    Does that mean if I were to have multiple ui documents with the same panel settings asset, there would be a performance dip as well? It's a bit unrelated to the issue since in this case I do need 2 panels but it would be helpful to know for other applications.
     
  5. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    I'm not sure where you got that from, all I said it's better to keep all your stuff in a single PanelSettings if you don't need panels with different settings.