drawOrder doesn't work as expected for elements

Hello,

What is the correct way of using drawOrder? According to the doc here and here it’s used to sort elements within the UI layer but its value is automatically reseted, apparently every time a new elements is added.

Here I tried to set the drawOrder to 100 but it’s reseted on the first tick to its order in the tree.
https://playcanvas.com/editor/scene/661615

Are we supposed to set the desired order on every tick?

I’m wondering if it was meant to be public API. I expected there to be some sort of flag/setting on the screen to allow a manual draw order in the elements but haven’t found it yet. All the usages in the engine suggest that if there is a screen, then the screen updates the order based on hierarchy every tick.

@vaios Any ideas here?

If you have a element as part of a Screen component we update the draw order automatically based on the order of your elements in the hierarchy, so any changes to drawOrder will be overwritten. For elements that are not in a Screen but are still in a manually sorted layer you can use the drawOrder property to set the render order.