Get the mouse position in the scene view

If you need to get the mouse position in the scene view in real time:

[CustomEditor(typeof(TileMousePosition))]

public class ShowInfo : Editor

{

     void OnSceneGUI(){

            TileMousePosition gameStart = (TileMousePosition)target;

            float much = 1;

            mult = EditorGUIUtility.pixelsPerPoint;

            Vector3 worldPosition = Event.current.mousePosition;

            Ray r = Camera.current.ScreenPointToRay(new Vector3(worldPosition.x, -worldPosition.y + Camera.current.pixelHeight));

            worldPosition = r.origin; //world coordinates of the mouse

      }

}

Guess you like

Origin blog.csdn.net/u011105442/article/details/103179732