Unity3D: put 3D objects above GUI surface

05 Nov

The default rendering results for GUI objects such as GUI textures, buttons, labels etc. are that they are overlaied above 3D views.

To do the opposite, for instance, make 3D view overlaied upon GUITextures, one can user layers and multiple cameras to achieve this.

  • Create a GUITexture object: in menu:  GameObject  arrow, dash, right icon  Create Other  arrow, dash, right icon  GUI Texture, let’s name it BackgroundTexture
  • Drop a 3D file, e.g. an obj file to the scene


  • Run the application, you will see that the GUI Texture is in front of the 3D object, and the 3D object is completely hidden


  • To bring the 3D object in front of the GUI Texture:
    • In the top right corner of unity, add a new layer called “background”

      image image 

    • Add a new camera, name it “Camera4GUI”,  in the Inspector, set the below parameters for this camera:
        • Layer: background
        • Clear Flag: Depth only
        • Depth: -1
    • Select the main camera, in the Inspector, set the below parameters for this camera:
        • Clear Flag: Depth only
        • Culling Mask: (Everything other than background) Mixed
        • Depth: 0
        • Uncheck GUI Layer checkbox

image   image

Rerun the application, now the 3D object is visible and in front of GUI object!


Download working Unity3d files.

Leave a comment

Posted by on November 5, 2013 in Programming, Unity 3d


Tags: , , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: