Hello everyone. I’m working on a game project on Unity 5.1.1f1 and I had to build it on the WebGL platform. In my game management script, I lock the cursor in the screen with the code below. It works in the editor but not after the build and the integration on the website. So when I want to turn the camera on a side, it is sometimes blocked.
It seems to be a recurrent problem on this forum, so I wonder if it is a Unity general problem (because of the new version) or this comes from my code ?
Here’s my code.
private bool lockCursor;
void Start() {
lockCursor = true;
}
void OnGUI () {
if (Input.GetKeyDown (KeyCode.Escape))
lockCursor = false;
if (lockCursor) {
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
else {
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
Thank you very much.