Quantcast
Channel: Questions in topic: "lockcursor"
Viewing all articles
Browse latest Browse all 92

Why Does This Script Freeze My Entire Unity Editor?

$
0
0
For some ungodly reason, whenever I try to implement this script, when I press play to test the game, it doesn't actually play. The cursor disappears and it hangs on the editor, not allowing me to do anything at all, which then requires me to close the program. I can NOT find the reason why this simple script would do this. I am also very new to scripting, so there could be something I am missing entirely. function Start () { Screen.lockCursor = true; } function Update () { while (Screen.lockCursor == true) { if (Input.GetKeyDown(KeyCode.Escape)) { unlockCursor(); } } while (Screen.lockCursor == false) { if (Input.GetKeyDown(KeyCode.Escape)) { lockCursor(); } } } function lockCursor() { Screen.lockCursor = true; } function unlockCursor() { Screen.lockCursor = false; } If anyone could explain why this is happening, I would greatly appreciate it.

Viewing all articles
Browse latest Browse all 92

Trending Articles



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