Last active
January 1, 2019 19:24
-
-
Save webthingee/5ff4b199712eb2b96fe44a7ef394862b to your computer and use it in GitHub Desktop.
Coroutines
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
void Start() | |
{ | |
Debug.Log(gameObject.name); | |
StartCoroutine(Main()); | |
} | |
private IEnumerator Main() | |
{ | |
yield return StartCoroutine(One()); | |
Debug.Log("Grid Complete"); | |
yield return StartCoroutine(Two()); | |
Debug.Log("Locations List Complete"); | |
} | |
private IEnumerator One() | |
{ | |
yield return new WaitForSeconds(2f); | |
} | |
private IEnumerator Two() | |
{ | |
yield return new WaitForSeconds(5f); | |
} |
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
StartCoroutine(WaitToExeute(1f)); | |
public IEnumerator WaitToExecute(float secondsToWait) | |
{ | |
// The waiting | |
Debug.Log("start wait " + Time.time); | |
yield return new WaitForSeconds(secondsToWait); | |
Debug.Log("end wait " + Time.time); | |
// Code to execute | |
isCharactersTurn = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment