I am having an issue with my cursor not disappearing when I press the esc key. If I press escape in my game, it brings up the exit game menu. If I click no (which means I don’t want to exit the game) everything works as intended. The menu disappears the cursor disappears and the controls are turned on. However if I press escape with the quit menu up the menu disappears (like it should), the controls are enabled (like they should) but the cursor remains on the screen (it’s supposed to disappear).
It seems like every time the esc key is pressed the cursol.lockstate is set to None, regardless of what is in the code. I think I am missing something simple. Here is the relevant code:
void Update () {
if (pointerVisable == true) {
Cursor.lockState = CursorLockMode.None;
ShipControlsActive (false);
} else {
Cursor.lockState = CursorLockMode.Locked;
ShipControlsActive (true);
}
if (Input.GetKeyDown (KeyCode.Escape)) {
if (quitting == false) {
quitting = true;
QuitGame ();
} else {
quitting = false;
StopQuit ();
}
}//end of esc key
}//end of Update
public void StopQuit(){
ExitMenu.SetActive (false);
pointerVisable = false;
}//end stop quit
public void QuitGame(){
ExitMenu.SetActive (true);
pointerVisable = true;
}//end QuitGame
Thanks In advance
Richard M.