I’m making a game and I want to release the mouse when the player presses Escape or P. How would I check if the mouse is locked or not?
You can use:
if(Screen.lockCursor == true)
to check if the cursor is currently locked.
But presumably you have gameplay where you want the mouse to be locked and then you want the mouse to be unlocked when you press escape or p so you can use a menu or something.
if(Input.GetKeyDown(KeyCode.P) || Input.GetKeyDown(KeyCode.Escape)) Screen.lockCursor = false;
when you want to unlock the mouse cursor. In the same function, you can also activate the menu or whatever you need the mouse cursor for.