Search Unity

Layering/Z-Ordering between UGUI and UI Toolkit

Discussion in 'UI Toolkit' started by burningmime, Jun 20, 2021.

  1. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    I want to do everything in UI Toolkit, but there are still some features of TextMeshPro I need access to that are not exposed in TextCore. So message boxes in my app are being rendered in UGUI while everything else is in UI Toolkit. However, it seems like the UI Toolkit will always render over the UGUI. Is there a way to control this, so I can render some message boxes above the Toolkit menu?

    Thanks!
     
    Suduckgames and brianpmaher like this.
  2. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Just tested and settings the Sort Order of a uGUI Canvas to 1 or higher draws the uGUI panel over the UI Toolkit elements. The UI Toolkit document also have the Sort Order property to control it from there if you need.

    I tested this with Unity 2021.1 and UI Toolkit preview 14

    ugui.png ugui2.png
     
    SkywardRoy likes this.
  3. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    @Leslie-Young what version of Unity and UI Toolkit are you using ?
    (unable to reproduce this on my side)
     
  4. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    @Midiphony-panda @burningmime Unity 2021.1.7 with UI toolkit Preview 14.

    My uGUI Canvas settings are, Screen Space Overlay with different values for Sort order.
    In the image below the red and green squares are each in their own uGUI Canvas.
    Red: Sort order 0. (bottom)
    Green: Sort order 2. (top)

    The rest of the UI is UI Toolkit with the UIDocument (component) Sort Order = 1. (middle)

    The Panel Settings asset also has a Sort Order option. I am not sure how this relates to what you can set in the UIDocument and mine is set to 0 there. So the UIDocument's value of 1 overrides this it seems.

    sort_order.png