I have custom editor window, and I’m trying to detect when my mouse is over a GUI texture that I can in the window.
I thought it seemed pretty straightforward, set wantsMouseMove to true, and then get the current event mouse position:
void Update () {
this.wantsMouseMove = true;
Vector2 mouse = Input.mousePosition;
Debug.Log ("MousePos: " + mouse);
}
Not so. For the mouse position, it always just prints (0.0,0.0) .
I also tried it this way, which I saw in another answer on here:
void OnGUI () {
wantsMouseMove = true;
EditorGUILayout.LabelField ("Mouse Position: ", Event.current.mousePosition.ToString ());
}
It sorta works, but it only changes the mouse postion when I click on the title bar of the window, or switch to another window/application and click back on the editorwindow.
I though this might have been an issue with my version of Unity, so I updated to the latest version (13GB download o_o) but no change.
Any ideas of whats happening here? I just need the get the current mouse position so I can use it in a Rect.Contains() in a GUI texture that’s is added to the window when you click the “add building” button.