- Home /
Gameobjects added to Canvas do not show in Game
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'm having a similar issue...
I have a prefab that has a Canvas inside (to hold the health bar of the unit, for example).
When I Instantiate the a new object from that prefab (In run time), the Image don't show up.
I'm setting the camera after Instantiating the prefab as...
canvas.worldCamera = Camera.main;
But when I add the Prefab to the scene and run the game, the Image does show up (Using the same script that attaches the camera).
What should I do to load a canvas on the fly? Is it even possible to do that?
Is there a workaround? Because I noticed google cardboard doesn't work anymore, (buttons at bottom are invisible, and my score counter doesn't exist anymore!
Answer by CanisLupus · Nov 22, 2014 at 02:30 PM
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.
Thank you @CanisLupus! The tip of changing the Canvas mode to something different than Overlay helped me solve the same problem. Only by just changing the Plane Value to one that was big enough I was able to make the GameObject visible in the Game$$anonymous$$ode again. Thanks again!
You're welcome! ;) Yes, depending on the camera near and far planes, the plane distance value can also be important. For UI I tend to set near to -1000, far to 1000 and then set the plane distance to 0, but it's just personal preference.
Answer by vtunity · May 28, 2016 at 01:19 PM
@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.
Seems to still be the case in 5.3.5f1. :( Does anyone know when a patch will be release to address this issue?
Just like those damn $$anonymous$$icrosoft updates in Windows 10, these things have not fully been TESTED, so why are we working in software that has not been fully tested. SI$$anonymous$$PLE ANSWER:Work out the bugs in these RELEASES, before they are released to the PUBLIC... (not rocket science)
Answer by gaaraofdesert9 · Oct 23, 2020 at 07:34 AM
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
Answer by gboudrias · Dec 29, 2021 at 12:02 AM
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).
Your answer
![](https://koobas.hobune.stream/wayback/20220613171919im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Showing text on top of a Slider, but not blocking Handler? 1 Answer
Android screen is small? 0 Answers
4.6 Button OnClick Super Sensitive to pointer movement. 1 Answer
Unity 4.6 - Detect Touch On Screen 1 Answer
Text Color Null Ref 1 Answer