- Home /
Display UI under the actual "Gameplay"?
Hey there!
I want to display a large score-counter in the middle of my scene. However, I notice that my GameObjects are moving underneath the Score-counter. At this time, I want to reverse that, but I didn't found any "Sorting-Layer" option in the UI Elements.
I would be grateful for some help!
Answer by tormentoarmagedoom · Oct 01, 2018 at 11:35 AM
I dont understand exatly what you mean... its a 2d game? Must the score panel move with the camera? And you want it under the game gameobjects? Then you can make a new canvas and set ta high number for the distance from the camera.
Bye!
https://i.imgur.com/ycqJGkN.png
This is how it looks. @tormentoarmagedoom
Answer by dan_wipf · Oct 01, 2018 at 03:40 PM
you can choose if you’re using sprite renderer what object is in front.
for example:
counter: Order in Layer: -1
rest: Order in Layer : 0
if you want to change order in layer of the counter:
getComponent<SpriteRenderer>().sortingOrder = 1 //if in front
getComponent<SpriteRenderer>().sortingOrder = -1 //if in back.
Unfortunately, the UI elements don't have a SpriteRenderer. @dan_wipf
then you might looking for gui.depth
Answer by eses · Oct 01, 2018 at 07:35 PM
HI @AnishsUsername
I'll assume you are using the current UI System, and not the legacy IMGUI system.
Some options:
Create a canvas.
A. Make the Canvas a World Space Canvas.
Then just place it behind your sprites, in front of your playfield.
B. Or alternatively, set your Canvas to "Screen space - Camera".
Then push the Plane distance behind your sprites. This might be easier.