Every time I finally get my IEnumerator method for a coroutine finally able to return a value, I get a blue screen and my hierarchy is empty. Is there something wrong with my code so I get a blue screen? If you know why, can you give possible solutions please?
Here's my method + other stuff pertaining the coroutine:
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) && playInfinite)
{
coroutineSFX = playSFX();
StartCoroutine(coroutineSFX);
Debug.Log("playInfinite is " + playInfinite);
}
}
private IEnumerator playSFX()
{
if (answer.text.Equals(word.text + " ") || (answer.text.Equals(word.text))
{
playInfinite = true;
playDing();
}
else
{
playInfinite = false;
playBuzz();
}
yield return new WaitForSeconds(1f); //wait a second
}
I tried returning a bool variable, unsurprisingly, it did not work.
I tried converting the bool variable, playInfinite, into an IEnumerator but I couldn't because I couldn't add reference, SystemCore.Assembly, required for the using System.Linq. I honestly did not know what I was doing.
At last, I added a pause, and the current result is the above method + blue screen.
If you wish to help solve and you find the information is insufficient, please inform me and I will try my best to do so. Thanks for checking my post. :)