Skip to content

Instantly share code, notes, and snippets.

@mindryu
Created November 9, 2014 12:57
Show Gist options
  • Save mindryu/4c51527c41cdcfd28c93 to your computer and use it in GitHub Desktop.
Save mindryu/4c51527c41cdcfd28c93 to your computer and use it in GitHub Desktop.
Unity3D WaitThenCallback
private IEnumerator waitThenCallback(float time, Action callback)
{
yield return new WaitForSeconds(time);
callback();
}
void Start()
{
splashScreen.show();
StartCoroutine(waitThenCallback(5, () =>
{ Debug.Log("Five seconds have passed!"); }));
StartCoroutine(waitThenCallback(10, () =>
{ Debug.Log("Ten seconds have passed!"); }));
StartCoroutine(waitThenCallback(20, () =>
{
Debug.Log("Twenty seconds have passed!");
splashScreen.hide();
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment