2D Gui Texture under 3D object

Is it possible to render a 3D model in front a Gui Texture?

In the following images you can see the enemy status overlays the player spaceship. What I want is exactly the opposite situation, with the spaceship that stays in front of the enemy status gui.

alt text

alt text

You could try to use 2 cameras (untested):

First:

  • with GUILayer

  • clear to skybox or solid color

  • lower draw order (depth)

Second:

  • no GUILayer

  • clear to “depth only”

  • higher draw order

there are two ways to do this. first of all you can use renderTextures. put the objects that you want to render in GUI in a seporate layer and tell the main camera to don't render that layer if you don't want them to be visible in the main scene. create another camera and tell it to render only that layer "we call it 3dGUILayer". then tell the new camera to render it's output to a rendertexture and draw the texture using a GUI.Label or GUITexture in your scene or even draw it on a GUI.Button or GUI.Label. the second way is to let the second camera (that renders 3dGUILayer) to render it's outtup to the screen but set it's clearing flag to depth only and set it's depth to a lower value to apear on top of the main camera. depth only tells the camera to render a transparent pixel in positions of the screen that it has nothing to render. then set it's position related to what you want to render to get the result that you want. renderTextures are a unity pro feature.

set it’s depth to a lower value to apear on top of the main camera. - “Cameras with lower depth are rendered before cameras with higher depth.”

This approach sounds like it will be a headache later on if you decide you want to add allot of different GUI elements, front and back.

Why not invest some energy into finding a 3D Plane approach? See if you could always face the flat plane with a texture towards the camera, then you can re-position that flat plane in front or in the back of the ship?!

Trust me, this will be less of a head ache later on, even if the flat plane texture doesnt look pixel perfect. :wink: