- Home /
My GUI elements are not rendering on top of all cameras. Any ideas why?
I was under the impression that all GUI elements are supposed to render over the top of every camera in the scene. I've opened a new scene and added two cameras, both with a gui layer, and with the depths of 0 and 1 respectively. I have resized the second camera's viewport rect and then created a GUI Texture (Gameobject > Create other > GUI Texture) from a transparent png frame. I'm confused as to why my second, resized camera is rendering over the top of GUI Texture whose Z has been set to 10. Could someone please explain to me why this is happening, am I missing a specific setting or something? Is it possible to get my GUI texture to be on top of the second camera? Any help is appreciated :)
Answer by Bunny83 · Mar 19, 2012 at 03:19 AM
Another way is of course to use a third camera just for your GUITexture / GUIText stuff and remove the GUILayers from the other cameras.
Thanks for your input Bunny83. If I use a third camera though, won't it appear as a simple rectangle/square like my second (red) camera in the image above, loosing the GUITextures outer border?
I suppose Bunny83 suggested you to set the Clear Flag of your third camera to "Depth Only" or "Don't Clear". You will be able to see through the frame transparency ins$$anonymous$$d having a background "Solid Color".
Although I would personnaly prefer the GUI method, the method described by Bunny83 works great too!
Sure ;) I don't use GUITextures or GUIText components. Well the "new" GUI system isn't perfect, but it's very powerful if used the right way ;) I just wanted to add another solution. The GUILayer component on a camera will render all GUITextures and GUITexts after the camera itself has finished rendering it's view. Therefore the GUI stuff will always be on top of the cameras view, but keep in $$anonymous$$d the cameras are drawn independently from each other. The camera with the lowest Depth value will be rendered first, the highest value at last. Usually you don't need to resize the viewport unless you need the clipping in some way.
Just a third camera with a high depth value that is responsible for rendering all GUI elements. Set the "Clear Flags" to "Don't clear", use a seperate layer for the GUITextures and set the "Culling $$anonymous$$ask" to render just this layer. Remove the GUILayer components from the other cameras. Now all GUITextures are rendered on top of all other cameras.
Brilliant idea! Just tried it out and it is exactly what I was looking for. I never would've thought of that. Really creative & really helpful answer!! Thank you
Your answer
Follow this Question
Related Questions
Apply Render Texture To GUI + Transparency? 2 Answers
GUI Texture not visible 3 Answers
Texture Size doesn't match collider size 0 Answers
Trying to make a Diablo like minimap, but I am having problems. Bug? 0 Answers
Path Trigger Animation 1 Answer