Cursor.setCursor hotSpot to center of image

I have a couple of custom cursors in my game’s shop. All of them need to have the hotSpot in the center of the image, but I’ve tinkered a lot with the hotSpot argument and I cant seem to get it away from the default top-left. Please help. Thanks.

image.width / 2 and image.height / 2 should do the job. Also, be sure to have your cursor images imported as cursors in the import settings.

Here is a full working example in C#:

using UnityEngine;
using System.Collections;

public class MouseScript : MonoBehaviour {

    public Texture2D cursorTexture;
    private Vector2 cursorHotspot;
    
    // initialize mouse with a new texture with the
    // hotspot set to the middle of the texture
    // (don't forget to set the texture in the inspector
    // in the editor)
    void Start () {
        cursorHotspot = new Vector2 (cursorTexture.width / 2, cursorTexture.height / 2);
        Cursor.SetCursor(cursorTexture, cursorHotspot, CursorMode.Auto);
    }

    // To check where your mouse is really pointing
    // track the mouse position in you update function
    void Update () {
        Vector3 currentMouse = Input.mousePosition;
        Ray ray = Camera.main.ScreenPointToRay (currentMouse);
        RaycastHit2D hit = Physics2D.Raycast (ray.origin, ray.direction);
        Debug.DrawLine (ray.origin, hit.point);
    }
}