Search Unity

Drawing 3D Objects over GUI

Discussion in 'Scripting' started by haveatyousnake, Nov 29, 2012.

  1. haveatyousnake

    haveatyousnake

    Joined:
    Nov 30, 2011
    Posts:
    14
    Hi,

    I'm trying to draw a 3D object in front of the GUI system I've made, it always goes under it though. Is there a way of handling this?
    All the GUI is being drawn using the OnGUI function and I'm having a bad time.

    Thanks guys.
     
  2. Landern

    Landern

    Joined:
    Dec 21, 2008
    Posts:
    354
    Have you tried using Layers? -> To the documentation!
     
  3. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Layers won't do anything. OnGUI elements are always drawn on top of the world.
     
  4. haveatyousnake

    haveatyousnake

    Joined:
    Nov 30, 2011
    Posts:
    14
    That's correct. So there's literally no way around having a 3d object in front? Or am I doomed?
     
  5. Landern

    Landern

    Joined:
    Dec 21, 2008
    Posts:
    354
    Yup, after digging around, you're right. :(
     
  6. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Not when using OnGUI.
     
  7. Whatbadguy

    Whatbadguy

    Joined:
    Apr 10, 2011
    Posts:
    165
    Wouldn't say that, you could use a RenderTexture, however this requires Unity Pro.. If you do have Pro you should have no problem duplicating whatever effects you want with that.
     
  8. Caliber-Mengsk

    Caliber-Mengsk

    Joined:
    Mar 24, 2010
    Posts:
    689
    You could also simulate a gui by using planes and scaling them to the aspect ratio and effectively make your own GUI system... but that's a fair amount of effort all in all to get it looking right on all different resolutions and having it fit the corners of the screen properly.
     
  9. BlankFoxGirl

    BlankFoxGirl

    Joined:
    Apr 26, 2010
    Posts:
    71
    Perhaps you could look to attach a camera to the 3D object, and make the camera render it's view as a texture, then draw that texture in your GUI.
     
  10. BlackMantis

    BlackMantis

    Joined:
    Feb 7, 2010
    Posts:
    1,475
    Thats what I was thinking too. Something like a renderTexture. (pro feature)

    (off topic) - Why devs place there PC stats on there signature?

    Is that just a bragging thing lol? What does the 1600x900 mean? Is that your screen res/size?