Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

3D objects as part of GUI

Discussion in 'Immediate Mode GUI (IMGUI)' started by Loraine, Jan 11, 2009.

  1. Loraine

    Loraine

    Joined:
    Jan 11, 2009
    Posts:
    15
    Hello,

    I'm a new Unity user, so please forgive my noob questions, but I can't find anything on this forum that explains how I could link gameobjects (3D Meshes) to my GUI.

    I tried to manually position them to correctly match the GUI texture, but when I run the game at different resolutions, they no longer line up.

    I thought I might have figured it out by using a ScreenToWorldPoint thing- but it's still not happy.

    Thanks in advance for any help you guys can give me.
     
  2. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    Adjust the position and scale of your 3d object based upon values you derive from Screen.width and Screen.height.
     
  3. rom

    rom

    Joined:
    Jul 2, 2006
    Posts:
    265
    you could :
    place your 3d object in the somewhere scene
    shoot it into a render texture
    use the renderTexture in a 2D gui
     
  4. Loraine

    Loraine

    Joined:
    Jan 11, 2009
    Posts:
    15
    Thanks for the suggestion Rom, but I am trying to avoid render textures if possible.

    I think I am heading in the direction you suggest, Quietus, but the fact that screen space starts from the bottom left (0,0) and GUI space is measured from the upper left, was giving me a headache.

    I think I have cracked it now though, but still need to figure out how to scale the object. Would it be simply a case of finding the correct scale for a particular resolution, then calculating a scaling percentage based on the player's selected screen res?

    I very much appreciate everyone's input.