I have a pause button but whenever I run my code it works fine the first time but then it disappears.
Here is code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseControllerScript : MonoBehaviour {
public string mainMenu;
public bool isPaused;
public GameObject pauseMenuCanvas;
public GameObject spawner;
public GameObject cups;
public GameObject button;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Update () {
if (isPaused) {
pauseMenuCanvas.SetActive (true);
Time.timeScale = 0f;
spawner.GetComponent <BallSpawn> ().enabled = false;
} else {
pauseMenuCanvas.SetActive (false);
Time.timeScale = 1f;
}
}
public void Resume () {
isPaused = false;
}
public void Quit () {
SceneManager.LoadScene ("StartScreen");
}
public void Yes () {
isPaused = true;
button.SetActive (false);
}
}