In my game I have a ball spawner that spawns a ball every time I tap the screen. I also have a pause button. When I tap the paused button, the spawner still spawns the ball even though I have told it not to using code. Here is my code:
Spawner:
public GameObject Ball;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
Instantiate (Ball, transform.position, Quaternion.identity);
}
}
}
Pause Buttons:
public class PauseControllerScript : MonoBehaviour {
public string mainMenu;
public bool isPaused;
public GameObject pauseMenuCanvas;
public GameObject spawner;
public GameObject cups;
// Use this for initialization
void Start () {
}
// Update is called once per frame
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 Paused () {
isPaused = !isPaused;
}
public void Yes () {
isPaused = true;
}
}