Created
September 2, 2016 14:31
-
-
Save renaudbedard/14e69379f34d42d3ae109047ad05c649 to your computer and use it in GitHub Desktop.
Nested coroutine stop problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo : MonoBehaviour | |
{ | |
Coroutine m_coroutine; | |
public void StartThing() | |
{ | |
m_coroutine = StartCoroutine(ParentCoroutine()); | |
} | |
public void EndThing() | |
{ | |
if (m_coroutine != null) | |
{ | |
// this stops the parent coroutine, but any ChildCoroutine that was in process will still complete | |
StopCoroutine(m_coroutine); | |
m_coroutine = null; | |
} | |
} | |
public IEnumerator ParentCoroutine() | |
{ | |
yield return ChildCoroutine(1); | |
yield return ChildCoroutine(2); | |
yield return ChildCoroutine(3); | |
} | |
public IEnumerator ChildCoroutine(float _varyingInput) | |
{ | |
// do stuff based on input | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment