I’ve got the following Hierarchy;
-
Canvas-
Panel -
Cube
-
The Cube is visible in the Scene on top of the Panel, however it is not visible in the Game.
How can I get my non-UI GameObjects to display inside a Panel?
I’ve got the following Hierarchy;
Canvas
Panel
Cube
The Cube is visible in the Scene on top of the Panel, however it is not visible in the Game.
How can I get my non-UI GameObjects to display inside a Panel?
I needed to know more about your setup, but it looks like a problem with layers and/or cameras. The Game view relies on camera settings to display objects. If an object is in a layer that no camera sees, it will not appear.
By default, Canvas comes configured in “Screen Space - Overlay”, in which it uses no Camera and will only show uGUI elements. If your Cube is the default Unity cube, it uses a MeshRenderer, and it won’t be visible inside an “Overlayed” Canvas, even if it is in the same layer as the Canvas. It’s only visible using some camera in the Canvas.
Two options:
1: Change the Canvas mode to either of the other modes (which use a camera). Then create a camera that sees the UI layer and change your Cube’s layer to “UI”. Drag the camera to the Canvas. As long as the camera position is adequate, you should see the cube.
2: Leave the Canvas in Overlay mode and just create a new camera that sees the layer your Cube is in (I’m guessing it is in the “Default” layer). This will work, but might not be what you want, as you’ll have a Canvas that sees uGUI elements only, and a camera that only sees the cube.
@staff0rd
Starting with 5.3.4p2, a bug in Unity prevents rendering World Space uGUI Canvases into a RenderTexture. Since RenderTextures are used for distortion correction, this effects all such canvases in VR.
This hurts to admit since I’ve been stuck with this problem for the last couple of days, but check the Alpha on your instantiated game objects’ prefab… I just found this out, and it hurt my brain… I am dumb sometimes, but if this can help anyone else, I would rather share my pain. XD
I had this issue with sprites in LTS 2020. If anyone else has this issue, check the scale of the resulting objects, at too small they simply won’t be rendered (this seems related to the way scaling works and not necessarily absolute size).