- Home /
2 cameras: 1 for GUI and 1 for GameObjects
Im using GUI to render some texture, buttons, text, etc. I need a GameObject to appear ON TOP of that things. With Unity usual behavior first render the GameObject and then, on top, the GUI (I need exactly the opposite).
Some people told me to create 2 cameras. One for the GUI and one for the GameObject. The exact words where :
just imagine 2 cameras next to each other, one is looking at box A at position x=0, y=0, z=0. The other is looking at box B at position x100 y100 z100. If the first camera is set to depth 1 and the second is set to depth 0 and the first camera is set to depth only, When you hit play, you will see both boxes in the scree. 2 images are rendered by placed on top of each other like paper.
I follow that instructions but nothing happens. Is that tip correct? Is that the way to do it? What Im missing?
**EDIT: I Found this and works PERFECTLY! http://www.41post.com/3255/programming/unity3d-creating-a-gui-with-both-3d-and-2d-elements**
I'm pretty sure the GUI will always be drawn on top of everything else.
As far as I understand, that's the way it works.
Answer by DarkSlash · Jan 09, 2012 at 05:24 PM
I found this and works PERFECTLY! :)
http://www.41post.com/3255/programming/unity3d-creating-a-gui-with-both-3d-and-2d-elements
Answer by Eric5h5 · Jan 09, 2012 at 04:45 PM
OnGUI code renders on top of everything and can't be changed. GUIElements (GUIText/GUITexture), however, can be layered with separate cameras.
@komodor: what are you talking about? The question didn't specify whether he was using OnGUI code or GUIText/GUITexture objects.
Answer by Hybris · Jan 09, 2012 at 06:06 PM
Couldnt you just use 2 cameras 1 with only render gui and the other with only render gameobjects or something like that?
Answer by Empus · Feb 23, 2018 at 06:39 PM
You can use WorldSpace render mode of a canvas.
Simply put your UI behind your model. Et voila!
Your answer
Follow this Question
Related Questions
GUI controlling other game objects 0 Answers
Camera Switching or Scene Changes? 3 Answers
"Press [e] to open" on stationary object when onTrigger 0 Answers
Render GameObjects over GUI.Layer 1 Answer
GUI Window on GameObject location? 1 Answer