Skip to content

Instantly share code, notes, and snippets.

@webthingee
Last active January 1, 2019 19:24
Show Gist options
  • Save webthingee/5ff4b199712eb2b96fe44a7ef394862b to your computer and use it in GitHub Desktop.
Save webthingee/5ff4b199712eb2b96fe44a7ef394862b to your computer and use it in GitHub Desktop.
Coroutines
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);
}
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