Quantcast
Channel: Questions in topic: "webgl"
Viewing all articles
Browse latest Browse all 2390

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

$
0
0
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. ![alt text][1] [1]: /storage/temp/49804-screen.jpg

Viewing all articles
Browse latest Browse all 2390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>