simply coded:
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
And there is nomore code changing the Cursor.lockState.
It works fine except when I’m using window mode, switching out with Alt+Tab. Then the mouse will not be locked at all, even after switching back and clicking inside the window many times.
I’ve tried development build, normal build and in-editor run, all of them have the same issue.
Unity version is 2018.1.6f1.