Skip to main content
Fixed the code.
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61

For whatever reason, Why when a certain boolean variable is true, the Unity editor crashes?

So inIn 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 completlycompletely.

Timer.cs

using UnityEngine; using System.Collections;

public class Timer : MonoBehaviour { public LevelManager levelManager;

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 isPauseisPause is true??

For whatever reason, when a certain boolean variable is true, the Unity editor crashes

So 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 completly.

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??

Why when a certain boolean variable is true, the Unity editor crashes?

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?

Source Link

For whatever reason, when a certain boolean variable is true, the Unity editor crashes

So 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 completly.

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??