Appearance order of screens

I have 2 screens in my scene. I want to send the front screen to back and back screen to front when launching. How can i do that??
https://playcanvas.com/editor/scene/1072109

Hi @mortal_phoenix,

For 2D UI elements the ordering order is from top to bottom how they are ordered in the entity hierarchy.

I think that holds true for screens as well, can you try that in editor?

1 Like

I tried but it’s still in same order

@jpaulo likely knows all about it

2 Likes

Played with an example project that holds three screens:

https://playcanvas.com/editor/scene/1312171

Indeed when the project launches the drawing order is from top to bottom (entity hierarchy).

But if you reorder any screen on runtime that isn’t respected anymore. One trick is to toggle on and off all screens, example code I’ve used in the browser console:

// run this twice to toggle on/off
pc.app.root.findComponents('screen').forEach(o => o.entity.enabled = !o.entity.enabled)

I wonder if there is an internal method that is used when that happens. Tried calling this but it didn’t work:

https://developer.playcanvas.com/api/pc.ScreenComponent.html#syncDrawOrder

2 Likes

We have a ticket a out controlling the order of UI screens here https://github.com/playcanvas/engine/issues/3514

The workaround for this is to have single UI screen with element groups as the container for ‘sub screen’ UIs and there order of rendering can be controlled by the hierarchy order.

2 Likes