Search Unity

GUI>Game interaction

Discussion in 'Immediate Mode GUI (IMGUI)' started by nickavv, Feb 19, 2008.

  1. nickavv

    nickavv

    Joined:
    Aug 2, 2006
    Posts:
    1,801
    How could I draw a GUIElement that stayed centered around a gameobject on the screen and that scaled as that gameobject got closer to or farther from the camera? Basically I need a way to figure out where on the screen the top-left and bottom-right pixels on a gameobject are at any given time, and make my Rect go between those. Any thoughts?
     
  2. Dafu

    Dafu

    Joined:
    Aug 22, 2006
    Posts:
    124
    Take a look at Renderer.bounds, which should return the bounding box in world space. Then you should be able to translate those coordinates with Camera.WorldToScreenPoint() and GUIUtility.ScreenToGUI().

    Just of the top of my head, I never used Renderer.bounds.