▲unity 更改鼠标光标外形-完美版

OnGUI可比,无点击闪烁bug 

 

    public Texture2D myCursor;
    public Texture2D myClickCursor;
    private bool cursorState = false;

    void Start()
    {
        Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); //隐藏默认光标
    }

    void Update()
    {
        //更改光标纹理
        if (!cursorState)
            Cursor.SetCursor(this.myCursor, Vector2.zero, CursorMode.Auto);
        else
            Cursor.SetCursor(this.myClickCursor, Vector2.zero, CursorMode.Auto);

        //判断鼠标状态
        if (Input.GetMouseButton(0))
            cursorState = true;
        else
            cursorState = false;
    }

 

转载于:https://www.cnblogs.com/subsystemp/p/3803202.html

你可能感兴趣的:(游戏)