- Home /
Question by
e-bonneville · Aug 02, 2010 at 08:47 PM ·
guicursor
GUI cursor position off
Hi, I'm overlaying a GUI texture to the position of the mouse. However, the actual click point, the end of the cursor, is off by a little to the left and up of my actual texture. How do I fix this?
Here's my script:
function Start() { Screen.showCursor = false; }
function OnGUI() { var mousePos : Vector3 = Input.mousePosition; var pos : Rect = Rect(mousePos.x,Screen.height - mousePos.y,cursorImage.width,cursorImage.height); GUI.Label(pos,cursorImage); }
Comment
Best Answer
Answer by Mike 3 · Aug 02, 2010 at 09:20 PM
You need to offset the rect by half the width and height:
var pos : Rect = Rect(mousePos.x - cursorImage.width / 2.0, Screen.height - mousePos.y - cursorImage.height / 2.0, cursorImage.width, cursorImage.height);
Your answer
![](https://koobas.hobune.stream/wayback/20220613070306im_/https://answers.unity.com/themes/thub/images/avi.jpg)