Hello, what i’m trying to do is have an editor script, that will have the usual EditorWindow, and be able to click in the scene view and return the position of a raycast hit in world space. I need it for instantiating etc…
I have tried using GUIPointToWorldRay, sending a ray from mousePosition in OnSceneGUI and a couple other ways, but i don’t know what i’m doing.
What am i doing wrong, and how can i fix it?
Thanks.
My code:
class rayEditorTest extends EditorWindow{
@MenuItem ("Window/Editor Test")
static function ShowWindow (){
EditorWindow.GetWindow(rayEditorTest, false, "Editor Test");
}
function OnSceneGUI (){
var r : Ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast(r, hit, 1000)){
Debug.Log(hit.point);
}
}
}