I am making an inventory and armor system and I want to create a background for the inventory system, I also want a 3D view of the character contained within the inventory panel,
To do that I would need to make my 3D model infront of the GUI background and I have no idea how to make this possible, seeing as the OnGUI function always renders at the front how would I do this.
I tried using a GUITexture which I was able to get behind my object but each time I save a reload unity it is pushed to the front of the scene again infront of the 3D model of my character.
thanks for your time and any suggestions you can give
P.S. yes the model does have to be 3D if it is possible as I want to allow rotating it to see different angles
Answer by DaveA
Aug 20, 2011 at 04:29 PM
If I'm not mistaken, you'd use a separate camera for that GUI-3d object, and set it's Depth closer than anything else, so it renders last.
thanks for answering, could you explain how I would set this up, would I have a camera attached to the 3D model that only renders that layer?
don't worry, thanks I sorted it... adding a new camera and model and set the model to a custom later made my main camera not render that layer and made the other camera only render that layer. Made the other camera orthographic and set the background to clear, and changed the normalized view area stuff so it all works now :) thanks for your help
Answer by jkivak
Apr 26, 2012 at 04:55 PM
Can anyone explain this in a little greater detail? For my situation:
I have a script using a semi-transparent black GUILayout.Box to display a wall of text. What I would like is a 3D model (the default unity Constructor for example), doing an idle animation in front of that GUILayout.Box, instead of being covered by the box.
I have a main camera, and a Constructor-only camera. I've added a new layer named "Constructor", and set the 3D Constructor model to that layer. The main camera culling mask is set for all layers EXCEPT "Constructor", and the second camera's culling mask will ONLY render the Constructor layer.
What do I do from here, to get the model to appear on top of the GUI box of text, instead of behind it?
Answer by kevinharte
Aug 23, 2012 at 01:09 AM
I'm not sure about default GUI boxes but I got the GUI health texture behind my boxer by having 3 cameras. The main camera doesn't use the layer the crowd plane is on or the texture. I then had the GUI texture on it's own layer. the main camera would show everything else, then you'd have to play with the depth settings on each camera. The main camera's depth would be the closest.
Still ironing out the code before I start to finalize the graphics. Been a real pain but we've been closing in on it now.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
6 People are following this question.
GUITexture Design-time positioning problems
Android tablet 10.1 and guiTexture gui placement with unity
Reduce Draw call for Multiple GUI Textures with same Texture
Using a GUI Movie Texture (making it appear and disappear correctly)