In my game I've got a timer script, which counts down unless the game is paused, but whenever the variable for pausing is true, something in the timer script makes the editor itself crash, and I have to pull out the task manager to close unity because it freezes up completely.
Timer.cs
using UnityEngine;
using System.Collections;
public class Timer : MonoBehaviour {
public LevelManager levelManager;
// Use this for initialization
void Start () {
levelManager = FindObjectOfType<LevelManager>();
StartCoroutine ("timerUpdate");
}
// Update is called once per frame
void Update () {
}
IEnumerator timerUpdate (){
while (levelManager.levelTimeSeconds>0) {
if (levelManager.isPause== false){
yield return new WaitForSeconds(1);
levelManager.levelTimeSeconds -= 1;
}
}
levelManager.isOver = true;
}
}
Anyone have any idea what's causing the editor to crash once isPause
is true?