|
How Can i retrieve a 2D screenspace position for a 3D gameobject? I'm trying to have a floating GUI.Label rollover identifying the object under the mouse position.
(comments are locked)
|
|
Camera.WorldToScreenPoint(position : Vector3) Keep in mind, Screen space has Y space going from bottom (0) to top (screen.height). GUI space y values go from top (0), to bottom (screen.height). Although for hover effects on geometry you may want to use MonoBehaviour.OnMouseOver instead, and then just sample the mouse position. Thank you, the OnMouseOver is what i'd been playing with after i asked the question and it does appear to work, but requires the Geometry to have a collider, and the script on each object, I think a 'manager' type approach using the WorldToScreenPoint will fit my needs better, thank you!
Dec 04 '09 at 12:31 AM
davebuchhofer
(comments are locked)
|
|
Here is An OnMouseOver() version that will hover a label over the mouse of the object under the mouse, I went with this one because there is an apparent tradeoff between using a Raycast check and the OnMouseOver, in that the raycast can still be triggered while you are clicking through a GUI, whereas the OnMouseOver stuff takes care of that for you? You sir, rock my world. Thanks for this :)
Aug 19 '12 at 05:20 AM
SpencerS
(comments are locked)
|
