Stopping a selected coroutine

Hi All,

Trying to stop a selected coroutine of the same method.
Is there a stop method to pass in a handle to a thread?

public IEnumerator crossFadeThread( AudioSource fadeOut, AudioSource fadeIn, float duration ) { ... }


StartCoroutine( crossFadeThread( sourceA, sourceB, 5.0f) );
StartCoroutine( crossFadeThread( sourceC, sourceD, 10.0f) );	
StartCoroutine( crossFadeThread( sourceE, sourceF, 7.0f) );	
	
OR using string method

StartCoroutine( "crossFadeThread", ... );
StartCoroutine( "crossFadeThread", ... );
StartCoroutine( "crossFadeThread", ... );

StopCoroutine( "crossFadeThread" );

Thanks

1 Answer

1

You can use StopCoroutine("coroutineName"), but only on Coroutines that were started using the string overload StartCoroutine("coroutineName")

EDIT:

missed the ‘thread’ bit. From what I’ve seen you can’t start/stop a coroutine from a thread that is not the main thread.