Last active
December 11, 2015 12:28
-
-
Save AnhPham/4600709 to your computer and use it in GitHub Desktop.
Pause Coroutine
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
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