Is there a Z-order of UI elements

Hi,
I couldn’t change z order of UI elements (image button etc.)
Is there any option for it?
Thank you.

Hi,

UIToolkit doesn’t support z-index at the moment. Parents are drawn before the children and you can control the ordering of the elements via the hierarchy. One way to do this is to use VisualElement.BringToFront and VisualElement.SendToBack.

1 Like

How do I use VisualElement.BringToFront I couldn’t figure it out.

Here is a thread with some great information! https://discussions.unity.com/t/756449

You simply call BringToFront() on the element that you want to be drawn on top.

For example if you have a container and you want the first child to be on top.

var container = new VisualElement();

//...

var firstChild = container[0];
firstChild.BringToFront(); // firstChild will now be the last children of the container

thanks