- Home /
detect mouse over object in the scene
hi,
How can I detect mouse over an object in the scene view with out using OnMouseOver function? I could really use an example script to detect mouse over.
Thanks
Comment
Best Answer
Answer by AlucardJay · Jun 25, 2013 at 12:53 AM
Raycast : http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
Debug.DrawLine (ray.origin, hit.point);
Debug.Log ("Raycast hit : " + hit.collider.gameObject.name);
}
Your answer