1
\$\begingroup\$

I'm currently trying to implement a UI that will overlay a scene and follow a scene's main camera, but I'm running into some issues. When I set canvas's mode to Screen Space - Camera, the Z position of the canvas is always set to 89.5, which is behind all of the objects that are generated into my scene, making the canvas and the UI elements on it completely invisible to the player.

This is the game preview before running the game, with the UI elements clearly visible:

enter image description here

This is the game while it's running in the editor, with the UI elements not visible at all:

enter image description here

This is what my hierarchy looks like:

enter image description here

This is what the properties for the canvas look like:

enter image description here

Why is my UI not visible when I run my game? How can I fix this?

\$\endgroup\$
0

2 Answers 2

4
\$\begingroup\$

Set the render mode of your camera to "Screen Space - Overlay". That way it will always be on-top of the actual game scene.

When you set the mode to "Screen Space - Camera", the "Plane Distance" determines what's drawn in front and what's drawn behind the canvas. Everything which is closer to the camera than the plane distance will be drawn in front. The objects in your game likely have a z-value of less than 100, so everything is drawn in front of the canvas.

For more information on the canvas render mode settings, see the documentation.

\$\endgroup\$
-1
\$\begingroup\$

Set the Z in the parent object to what you want it to be and try it again.

\$\endgroup\$
1
  • \$\begingroup\$ What parent? The canvas is currently by itself with no parent. Creating a parent object for the canvas and setting the Z value to something different doesn't change a thing either. \$\endgroup\$ Apr 17, 2016 at 19:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .