- Home /
"Playable state" is not reverting in function "ExitConfFalse()"
I made a script to bring up a dialogue when the player presses ESC to confirm whether they want to exit or not. But the "no" option (calls my function ExitConfFalse()) only locks the cursor back in place, not re-enabling the player.cs script or hiding the dialogue box. My script is as follows:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Exit : MonoBehaviour { public GameObject exitConf; public MonoBehaviour Player; void Start() { exitConf = GameObject.FindGameObjectWithTag("ExitConfirmation"); exitConf.SetActive(false); Cursor.lockState = CursorLockMode.None;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Player.enabled = false;
exitConf.SetActive(true);
}
}
public void ExitConfTrue()
{
Application.Quit(0);
}
public void ExitConfFalse()
{
exitConf.SetActive(false);
Player.enabled = true;
Cursor.lockState = CursorLockMode.Locked;
}
}
(Please Excuse the weird formatting! I don't know what happened!)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Creating GameObjects and MonoBehaviours 1 Answer