CursorLockMode

hi !

I going to turn crazy, after many day of research, i can’t figure out of my problem, i use CursorLockMode to lock my cursor in the center of my screen, but when i do that i can’t use UI in global space, i have to unlock my cursor to press any button …

What i want is to have my cursor invisible and center to my screen and still can press button … I tryed to perform raycast from the center of my screen with camera.ScreenPointToRay(Input.mousePosition) but that not work …

Please help me

Use this:

Cursor. Lockstate= CursorLockMode. Locked

if (Input. GetKey("escape" ))
{
     Cursor.lockState = Cursor.LockState.Unlocked;
}

That means if you press the Esc button it will unlock the cursor