- Home /
Showing a layer with GUI Box(Behind layer) on click of game Object
I have 2 layers on the current scene,One which is visible by default and contain certain GameObjects
and custom layer which appear only when those GameObjects
are clicked. When this custom Layer appears ,A GUI.BOX
should appear behind this layer.But what happens currently is,`GUI.Box` appears on top of everything. While searching for solution, there are certain links which says create another camera and set clear flags
to depth Only
,Culling Mask
to that layer ,Which I did ,but it shows GUI.Box above every layer.
The solution with layers/cameras will work in case of GUITexture
, but not in case of GUI.Box
(or any other GUI elements drawn in OnGUI
). These elements are always rendered on the top of everything else.
Answer by Patel-Sagar · Dec 27, 2013 at 09:58 AM
You can do this by taking another camera for custom layer, then call 2ndCamera.Render() at last line of GUI() method where you have defined GUI.Box().
This will render camera's 3D view on GUI of 1st camera.
Just one question,I have a back button on the scene which appears when the scene loads .When the layer appears ,I am able to click the button which i dont want. Though the action are controlled ,but still I don't to happen that. Is there anyway for it
sorry buddy i didn't get your question. but if you want to just disable the button, you can do it by setting boolean at scene load in Start function.
What I mean is :: there is a GUI.Button
(Back Button) when the scene loads. Now when the layer appears,I dont want the back button to take any events(Click,Hover etc ). As of now it takes those events so I have to use boolean variable so that it doesn't perform any action. Is there any way that it doesn't take any event at all when the layer is visible.