Coroutine doesn't continue after checking for bool

by Milen   Last Updated May 16, 2016 09:05 AM

I have the following coroutine:

    public IEnumerator EndGame() {
    //StopAllCoroutines();
    GamePauseController.instance.UnfreezeTime();
    DisintegratorModalController.instance.ignoreBorderDisin = false;
    ignoreBorderEndGame = true;
    StartCoroutine(CubeBehavior.instance.DestroyCubesGameOver());
    StopBackgroundMusic();
    DisableCubeSpawner();
    CubeBehavior.instance.ClearSelectedCubes();
    ScoreManager.instance.StopCountingScore();
    GameDataManager.instance.SaveHighScoreAndDisintegrators();
    ScoreManager.instance.SaveScoreToLeaderboard();
    LightColorManager.instance.WhiteFadeToHeartbeat();

    while (!CubeBehavior.instance.allCubesDestroyed) { // Wait for all the cubes to be destroyed before continuing
        yield return null;
    }

    Debug.Log("Working");
    StartCoroutine(HUDController.instance.HideHUD());
    StartCoroutine(GameResultsController.instance.ShowResultsMenu());
    MenuParticles.instance.Show();
}

After the bool check the code below it doesn't execute when it should. What is the issue here?

Tags : unity coroutines


Related Questions





NullReferenceException in StartCoroutine method

Updated November 25, 2016 08:05 AM

Best way to queue animation coroutines in unity

Updated April 15, 2017 00:13 AM