Sort Order not respected with UI Toolkit

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
KoryCode
Posts: 3
Joined: Thu Apr 25, 2024 6:06 am

Sort Order not respected with UI Toolkit

Post by KoryCode »

I run into an issue where the dialogs are always appearing on top.
Even if I set the sort order of my pause menu to extreme high numbers into the thousands.
The dialog system still appearing on top with a sort order of 100.

I would like to show my pause menu on top the dialog.
my pause menu using UI Toolkit not canvas, but that should not mater
Screenshot 2024-04-25 113609 sm.png
Screenshot 2024-04-25 113609 sm.png (185.02 KiB) Viewed 48 times
Could you help me please?
User avatar
Tony Li
Posts: 20685
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sort Order not respected with UI Toolkit

Post by Tony Li »

Hi,

There's nothing specific to the Dialogue System. Is the Canvas that contains your dialogue UI a Screen Space - Overlay canvas? Its default sort order should be 0, not 100, although you're free to change it.

Are you using Unity 2021.2 or higher? Sort order compatibility between the two UI systems was added in 2021.2.
KoryCode
Posts: 3
Joined: Thu Apr 25, 2024 6:06 am

Re: Sort Order not respected with UI Toolkit

Post by KoryCode »

I'm on 2022.3.16
I have changed the sort order of the Dialog Manager canvas to 10 now the pause Menu (sort order 50) is over it. which is correct.

But the animal selector which is also UI Toolkit with sort order 0 appears over it now.
I'm using Screen Space - Overlay for the dialog.

It is weird. I guess it is not a dialogue system but a Unity issue.

Maybe I just move the dialog system out of screen while the Pause menu is open.
Or maybe it is possible to hide it without loosing it state (as it is paused)
Screenshot 2024-04-25 225627.png
Screenshot 2024-04-25 225627.png (922.25 KiB) Viewed 37 times
User avatar
Tony Li
Posts: 20685
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sort Order not respected with UI Toolkit

Post by Tony Li »

Hi,

The easiest way to reliably hide it without losing its state is to disable its Canvas. Example:

Code: Select all

DialogueManager.displaySettings.defaultCanvas.enabled = false;
Then enable it again when you close the pause menu.
KoryCode
Posts: 3
Joined: Thu Apr 25, 2024 6:06 am

Re: Sort Order not respected with UI Toolkit

Post by KoryCode »

Thank You Tony! That actually works very well and looks better than if I overlay it! Awesome!
User avatar
Tony Li
Posts: 20685
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sort Order not respected with UI Toolkit

Post by Tony Li »

Glad to help!
Post Reply