New added StopCoroutine(Coroutine coroutine) override function causes errors.

When StopCoroutine(Coroutine coroutine) used on coroutine that has been yielded by WaitForSeconds(delay), coroutine produces “Coroutine continue failure” in console when it tries to resume. Is this a bug, or intended feature? (C# language, if it matters)

I have this exact same question.

Anyone?

halp. that is all.

Add me to the list. The error doesn’t seem to have an impact on anything, but it would be nice to know why it does result in an error and how we can avoid this behavior…

Same error too. X(

Same error ++;

The same error in 4.6.1p3

Hi people, I’ve seen this too. Has anyone already submitted it as a bug report?

The same error in 4.6.1f1

Same error too

Works if you store the IEnumerator instead of the Coroutine and use that to stop the function. But yes, with the Coroutine, that error appears…

Has anyone submitted a bug report?

Same issue here.

Stopping via Coroutine reference returns an error “Coroutine continue failure”.
Can also confirm that stopping via IEnumerator works though.

Yup, same issue here.

Bug number would really help

I reported the bug, with the bug number 665426.

Thanks! :slight_smile:

I just put this into the docs for 5.0. This does not cause the error the post describes. StopCoroutine is documented as taking an IEnumerator. Passing in a Coroutine seems to work but triggers the error.

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {

    private IEnumerator coroutine;

    // Use this for initialization
    void Start () {
        print("Starting " + Time.time);
          coroutine = WaitAndPrint(3.0f);
          StartCoroutine(coroutine);
        print("Done " + Time.time);
    }

    public IEnumerator WaitAndPrint(float waitTime) {
        while (true) {
            yield return new WaitForSeconds(waitTime);
            print("WaitAndPrint " + Time.time);
        }
    }
   
    void Update () {
        if (Input.GetKeyDown("space")){
            StopCoroutine(coroutine);
            print("Stopped " + Time.time);
        }
    }
}
2 Likes

As of 4.6, a feature in the patch nodes (but not the Unity Docs) is that Unity takes a Coroutine for StopCoroutine. (This can be found here, under Improvements:

This is the third method for using StopCoroutine, with the other two using an IEnumerator and string (yuck) as parameters.

This thread is not about the StopCoroutine(IEnumerator routine) method, but the StopCoroutine(Coroutine routine) method. While it’s true that they are fundamentally very similar, there is one difference: with the IEnumerator method, care has to be taken that the IEnumerator isn’t used in multiple StartCoroutines, as a StopCoroutine(IEnumerator routine) call stops all Coroutines started with that IEnumerator. With the Coroutine method, this isn’t possible, as the Coroutine instance is a return from the StartCoroutine call.

Really, we’re just wondering what’s up with the error. Is it something that we can ignore? Thanks for the quick response!

I think I fixed this in 4.6.1p4. The warning is annoying, but ultimately harmless.

1 Like