In my game I have a pause menu. I also have a button that makes the pause menu pop up. The pasue menu has buttons to resume the game and quit. I have a spawner that spawns a prefab. To make the spawner work I have a transparent button the size of the entire scene. When I click this button to make the ball spawn, the entire game stops.
Spawn Ball:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallSpawn : MonoBehaviour {
public GameObject Ball;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Update () {
}
public void Yep () {
Instantiate (Ball, transform.position, Quaternion.identity);
}
}
Pause Menu:
using UnityEngine.SceneManagement;
public class PauseControllerScript : MonoBehaviour {
public string mainMenu;
public bool isPaused;
public GameObject pauseMenuCanvas;
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;
} else {
pauseMenuCanvas.SetActive (false);
Time.timeScale = 1f;
}
}
public void Resume () {
isPaused = false;
}
public void Quit () {
SceneManager.LoadScene ("StartScreen");
}
public void PauseMenuOpen () {
isPaused = true;
button.SetActive (false);
}
}
The pause button works though