Search Unity

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

3D to 2D Point

Discussion in 'Immediate Mode GUI (IMGUI)' started by matrix211v1, Jul 14, 2010.

  1. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    Hello All!

    I am trying to make a login page, and I have a slight twist to it. I need to get the position of a gameobject in 3D space, figure out what is that in the current viewpoint in 2D.

    The best way I can describe it would be if I had a 3d mesh of a billboard in the scene. On the billboard, I have on the texture that has the names "Login" and "Password". I need to use OnGUI to match the same locations on the texture but the issue is, people can resize the window browser and therefore the billboard positions is no longer in the static place.

    My goal was to make empty GameObjects on the corners of the texture login and hopefully read their 2D positions and make the OnGUI put the label there.

    Hope this makes sense. I can make a screenshot if someone is confused.

    Thanks for the help!
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You can use Camera.WorldToScreenPoint for this. I would recommend following your plan of using GameObjects as marker points for the text fields since it sounds like the easiest way to go.
     
  3. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    You... are a life saver! Thanks!