Hay, how do i get the mouse position on screen?
I can get mouse X, but it's in relation to the top left of the screen. I was the mouse position from the center of the screen. So the top left with be minus something, and the center will be 0.
Hay, how do i get the mouse position on screen?
I can get mouse X, but it's in relation to the top left of the screen. I was the mouse position from the center of the screen. So the top left with be minus something, and the center will be 0.
var mousePos = Input.mousePosition;
mousePos.x -= Screen.width/2;
mousePos.y -= Screen.height/2;
You can also use the OnGUI callback function
void OnGUI () {
Event currentEvent = Event.current;
if (currentEvent.isMouse) {
Vector2 mouseXY = new Vector2 (currentEvent.mousePosition.x - Screen.width/2, currentEvent.mousePosition.y - Screen.height/2);
// AND DO THE REST
}
}
See also:
http://docs.unity3d.com/Documentation/ScriptReference/Event-current.html
http://docs.unity3d.com/Documentation/ScriptReference/Event-isMouse.html