- Home /
Camera Viewport issue: Being Drawn Behined GUI
Hi,
I am coding a project right now that requires a view port within another cameras view port. As I have been doing this I have been setting the camera which is being drawn over the much larger camera's view-port to a higher depth. My issue is when The camera is being drawn the much larger camera's GUI is being drawn over the smaller one's Rectangle on the screen. The smaller view-port on the screen that I am trying to make to be at the front does not have a GUI Layer component attached to it. If anyone could help with this problem it would be greatly apreciated.
Thank you and have safe and fun holidays,
Jacob
Sorry, I must of clicked the wrong thing when I was putting in the image.
Answer by jahroy · Dec 23, 2011 at 08:33 PM
The GUI will always be drawn over everything else.
If you don't want your GUI to be drawn over your smaller viewport, you need to draw the GUI elements and the viewport in different locations.
Your script must know where the small viewport is. You need to lay out your GUI controls so they're not in that rectangle.
You can get the pixel coordinates used by a camera's viewport by using Camera.pixelRect.
ok, So maybe just thinking, the only GUI. Box that will be staying is the Largest one around the whole thing. That will be used to create the background in the " In Game PC application " (its being replaced with an opaque texture at some point). But maybe Ins$$anonymous$$d of doing that I could use the monitors background material as the UI's Background. Then the camera shouldn't have any problems right?
Check out Camera.clearFlags (I think that's what you're after):
http://unity3d.com/support/documentation/ScriptReference/Camera-clearFlags.html
(you can also tweak the clear settings in the Inspector)