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