Unity 5.1.1f1 - WebGL : Lock cursor in the screen not working

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.

This is a bug in the current version. Sorry for the troubles.

You can follow it at http://issuetracker.unity3d.com/issues/webgl-cursor-dot-lockstate-does-not-work-as-expected

The mouse lock keeps forcing me to look up on my chromebook
. I need help with this,whenever I try to play a game, the mouse lock works, but when it locks it forces me to look up, I am so confused, anyone have a solution. because I’m playing these webgl games on my chromebook.