Mouse Pointer problem

Hi Guys

I have this small problem im using a custom texture for the mouse pointer but the texture does not properly aline with the mouse pointer (Please see the attached image)

I want it to aline it properly with the mouse pointer.

Please help

thank you

389972--13413--$aim_171.jpg

looks perfectly correct. Upper left edge is the hotspot.

Or do you want the hotspot to be in the middle of the image? Then you have to translate your image coordinates so the mouse position is in the center of the image.

  ImagePosX = MouseX - ImageSizeX / 2.0f;
  ImagePosY = MouseY - ImageSizeY / 2.0f; //maybe "+" instead of "-" here. Can't test actually

Hi vastor

Thanks for the reply, Yes I want the hotspot to be in the middle of the image, Il check it out.

thanks again.

Hi vastor

I tried using ur method n its working properly however now the CrossHair movement is inverted if i move my mouse course up the crosshair moves down (See Image).

Also here is the code im using, Im using C#:-

public class Aim : MonoBehaviour {
	
	public Texture crosshairTexture;
	
	// Use this for initialization
	void Start () {
		
	}
	// Update is called once per frame
	public void OnGUI () {
		Vector3 Mouseposition = Input.mousePosition;
		float ImagePosX;
		float ImagePosY;
			ImagePosX = Mouseposition.x - crosshairTexture.width / 2.0f;
			ImagePosY = Mouseposition.y - Screen.height / 2.0f;
			Rect Position = new Rect(ImagePosX,ImagePosY,crosshairTexture.width,crosshairTexture.height);
			GUI.Label(Position,crosshairTexture);
	}
}

390030--13414--$aim_172.jpg

Better write :

Missing part :

Hey AkilaeTribe

Thanks for the Help it works perfectly now ,Here’s the the final Code could be useful for any one in future

	public void OnGUI () {
		Vector3 Mouseposition = Input.mousePosition;
		float ImagePosX;
		float ImagePosY;
			ImagePosX = Mouseposition.x - crosshairTexture.width / 2.0f;
			ImagePosY = Mouseposition.y + crosshairTexture.height / 2.0f;
			Rect Position = new Rect(ImagePosX,Screen.height - ImagePosY,crosshairTexture.width,crosshairTexture.height);
			GUI.Label(Position,crosshairTexture);
	}