Search Unity

3D object in OnGUI

Discussion in 'Immediate Mode GUI (IMGUI)' started by Riash, Dec 23, 2011.

  1. Riash


    Nov 1, 2011
    Hi All,
    I new to gaming platform and i am developing a small 2D game in Unity3D. i want to display a piechart in OnGUI so that i searched forum but i couldn't find out related stuff . unfortunately i got one piechart but that is in 3Dobject. How can i show the 3D object in OnGUI. so that i searched forum related to display the 3DObject rendering in OnGUI. they said use a second camera to display the 3D object above onGUI. i dont know how to do it . please give tutorial to do that.

  2. Ted-de-Munnik


    Mar 13, 2011
    You cant use a 3d object directly in your GUI, but you can create a second camera that creates a render texture, or renders to a custom viewport.
    If you set the camera 'clear flags' to no-clear, it will make the background transparent. Just put the depth of that camera higher than the default camera, otherwise it won't show up.
    Also a nice thing to do is create a different render layer for '3d gui' and make your gui camera render only this layer.