Home > Mobile >  custom cursor not showing up
custom cursor not showing up

Time:08-25

I'm pretty new to c# and unity, and I was trying to make a custom cursor by attaching this code to the cursor gameobject. In the inspector, I can see that the gameobject is clearly following the mouse, but the gameobject just disappears when I start the game.

    void Start()
    {
        Cursor.visible = false;
    }

    void Update()
    {
        Vector3 cursorPosition = Input.mousePosition;
        transform.position = cursorPosition;
    
    } 

CodePudding user response:

You should use this function to set a new cursor Texture Cursor.SetCursor(Texture2D,CursorMode)" if you want to do it at runtime. Also you can set the default cursor on menu Edit > Project Settings > Player > Default cursor

Documentation of this Method

Also you have to configure the Texture import to be a type cursor Texture, you can find the documentation of how set up a Texture cursor on this link:

Texture type Documentation

  • Related