Answer the question
In order to leave comments, you need to log in
How to properly Raycast in the editor window?
Hello dear experts.
I'm making a stray in my custom inspector that would display data (detailed information) on the object over which the mouse cursor is currently located in the scene editor window. The objects are all 2D sprites.
I have compiled the following code, but it does not work for me:
Ray ray = Camera.main.ScreenPointToRay (Event.current.mousePosition );
Debug.Log(ray);
RaycastHit hit;
// Shoot this ray. check in a distance of 10000.
if (Physics.Raycast(ray, out hit, 10000))
{
Debug.Log ("Raycast hit name: " + hit.collider.gameObject.name);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question