I'm trying to write a pause script and I can't figure out how to unpause properly. Can anybody help? Here's what I have but it's not working:
#pragma strict
var gamePaused : boolean = false;
function PauseGame() {
if(gamePaused == false && Input.GetKeyDown(KeyCode.Escape) == true || Input.GetButtonDown("Start")) {
Time.timeScale = 0;
gamePaused = true;
}
}
function UnPauseGame() {
if (gamePaused == true && Input.GetKeyDown(KeyCode.Escape) == true || Input.GetButtonDown("Start")) {
Time.timeScale = 1;
gamePaused = false;
}
}
function Update() {
PauseGame();
UnPauseGame();
}
↧