- Home /
Question by
surfuay · Nov 30, 2018 at 01:02 AM ·
coroutinepause gamestopcoroutine
I'm stopping coroutines in pause but can't bring them back
I've been working on a pause function. I've gotten my game to "freeze" using time.timescale = 0 but it doesn't stop the spawn routine so when I unpause i have a wave of new whatever coming into my play area.
BUT, when i use code to StopAllCoroutines, i can't get it to start up again.
the current code, below, i've posted is another method i've tried but since it's in update it calls a new spawnroutine frame as long as "else if (_uIManager.pause_visible == true)" which is the default aspect.
I am open to different ways to pause the game as well as different ways to get my coroutines to hold off. I am only posting the game manager code which holds the calling and the stopping of the coroutines based on the pausing.
public bool gameOver = false;
public GameObject player;
private SpawnManager _spawnManager = null;
private UIManager _uIManager;
private void Start()
{
Instantiate(player);
gameOver = false;
_uIManager = GameObject.Find("Canvas").GetComponent<UIManager>();
_spawnManager = GameObject.Find("SpawnManager").GetComponent<SpawnManager>();
_spawnManager.StartSpawnRoutines();
}
private void Update()
{
if (_uIManager.pause_visible == false)
{
StopAllCoroutines();
}
else if (_uIManager.pause_visible == true)
{
_spawnManager.StartSpawnRoutines();
}
}
Comment