Skip to content

Instantly share code, notes, and snippets.

@AnhPham
Last active December 11, 2015 12:28
Show Gist options
  • Save AnhPham/4600709 to your computer and use it in GitHub Desktop.
Save AnhPham/4600709 to your computer and use it in GitHub Desktop.
Pause Coroutine
private bool isPause;
public Coroutine Sync()
{
return StartCoroutine(PauseRoutine());
}
public IEnumerator PauseRoutine()
{
while (isPause)
{
yield return new WaitForFixedUpdate();
}
yield return new WaitForEndOfFrame();
}
// Example:
private IEnumerator Test()
{
Debug.Log("0");
yield return new WaitForSeconds(3f);
yield return Sync(); // Check pause here
Debug.Log("1");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment