Mouse position problem...

Hi,

I’m doing some tooltips, and I want them to follow my mouse cursor.

I’m using :
in the “on Update”

MX = Input.mousePosition.x;
MY = Input.mousePosition.y;

in the “OnGUI”

GUI.Button(new Rect(MX, MY, 75, 75), "", MyGuistyle);

And my button isn’t on the mouse position, and the Y axis (height) is inverted(reflection on the horizontal axis), when I go up the button goes down.

is the problem could come from this line ? (resize the GUIs)

GUI.matrix = Matrix4x4.TRS(new Vector3(0f, 0f, 0f), Quaternion.identity, new Vector3(horizRatio, vertRatio, 1));

this is my first line in my On GUI.

Here is a screenshot (i put the mouse position in red (no cursor in print screen))

Any ideas for where it come from or how to correct that ?

Cheers

BooBi

The Y coordinate for the mouse position increases upwards on the screen but with the GUI system, it increases downwards. You just need to subtract the mouse Y coordinate from Screen.height to convert to GUI coordinates.

It doesn’t just seem to be the mouse. If I query the screen rect for a texture at the bottom right of the screen I get (800,0,200,50). If I create a label at those coordinates it appears at the top right. This is a bug, I’ll report it.