- Home /
3D object on top of GUITexture on top of GUI
So Here is my inventory Inventory renders in this fashion: GUITexture, 3D object (from second camera/layer), GUIElements (all the items and slot icons) Healthbar and QuickSlotbar renders on top of everything
Question is simple: Is there any posible way to make inventory go ON TOP of healthbar and quickSlots and make 3D object (character model) go on top of inventory? !? Without turning everything into GUITextures ?!
Also you are free to convince me to change everything into GUITextures what is an absurd in my perspective. GUITextures are SO HARD to manipulate, I hate to even have inventory just for the sake of 3D object that I what to showcase.
Does Unity really want me to find another way to represent my character? If so... facepalm
(let me know if anyone needs more details so maybe I would have to make a video about it or something...)
Answer by Bunny83 · Nov 19, 2013 at 12:35 PM
You can simple disable your inventory camera(s) and render them manually in OnGUI.
//C#
public Camera inventoryCamera;
void OnGUI()
{
// your healthbars
if (Event.current.type == EventType.Repaint)
{
inventoryCamera.Render();
}
}
Keep in mind that the order you call stuff in OnGUI determines what is on top of what. I've used this quite often to render 3D objects on top / inside OnGUI GUIs ;)
I felt there was a better way to do it. Thanks for sharing this great tip :3 Definetly makes me feel releaved.
Answer by gajdot · Nov 18, 2013 at 07:30 PM
What you could do is to render your inventory to another camera and make the zOrder of it higher I belive. So you need to add another camera to the scene, give your gui a new layer, make the secondary camera render only that layer in the camera settings, and on the main camera render everything except that layer.
Not a very helpful advice. Obviously not a solution at all if I get it right. You see inventory contains of 3 layers. I already use secondary camera to capture 3D object (that human character) and put it where it belongs. You don't mean I can actually capture the whole GUITexture + 3D object + GUI elements and put it on top of the screen do you? Because if so I have still no idea how to do so.
EDIT: yep I can't even figure out how to render GUITexture in a different layer. The thing with cameras was already clear to me.
you can place guitextures on top of each other by changing their transform z axes. as for the gameobject i don't know how to help you get it in between guitextures.
Yeah, this depth thing is so damn hard (or should I say unrefined?)... Either you make a completely 3D "GUI" or use JUST GUIElements and GUITextures... $$anonymous$$aybe I should look for game examples, I still hope that what I am trying to do is posible.
I believe I misunderstood you. If your inventory is a GUITexture then just change it's z position to be higher(if I remember right, if not then lower :) ) then your health bar and to render your 3d object (your character?) even front of them, move it to a unique layer and do the trick I said.