using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CursorWorkaround : MonoBehaviour
{
    public Texture2D unlockedCursor;
    public Texture2D lockedCursor;
    private CursorLockMode oldCursorMode = CursorLockMode.None;

    void Start() {
        UpdateCursor();
    }

    void Update()
    {
        if (oldCursorMode != Cursor.lockState) {
            UpdateCursor();
        }
    }

    void UpdateCursor() {
        if (Cursor.lockState == CursorLockMode.Locked) {
            Cursor.SetCursor(lockedCursor, Vector2.zero, CursorMode.Auto);
        }
        else {
            if (unlockedCursor != null) {
                Cursor.SetCursor(unlockedCursor, Vector2.zero, CursorMode.Auto);
            }
            else {
                Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
            }
        }
        oldCursorMode = Cursor.lockState;
    }
}
