title: Unity EditorWindow - find mouse position in sceen view
body: <p>I've been googling and trying to find an answer to this. But I've come up with absolutely nothing. </p>
  
  <pre><code>private static void OnSceneGUI(SceneView sceneView)
  {
      // var mousePos = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
      // Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
      Ray ray = Camera.current.ScreenPointToRay(Event.current.mousePosition);
      Debug.Log("Screen: " + ray);
  }
  </code></pre>
  
  <p>This is what I've come up with now, to find the mouse position.</p>
  
  <p><a href="https://i.stack.imgur.com/a5yX1.png" rel="nofollow noreferrer">It seems that the X is always right, but the Y and Z is following the zoom of the camera, not the mousePos on screen.</a></p>
  
  <p>My goal is to find mousePos and then reset playerPos to where my mouse is.</p>
  
  <pre><code>[MenuItem("MyMenu/DevTools/ResetPlayer #r")]
  private static void ResetPlayer()
  {
      var player = GameObject.Find("Player");
      Transform playerPos = player.GetComponent&lt;Transform&gt;();
      Vector3 reset = new Vector3(-7, 0, 0);
  
      playerPos.position = reset;
  }
  </code></pre>
  
  <p>For now I've only figured out how to reset to a fixed position. </p>
  
  <p>I am very new in this editor coding, so I appreciate all help I can get! :) </p>