Skip to content

Instantly share code, notes, and snippets.

@x5lcfd
Last active June 1, 2016 13:58
Show Gist options
  • Save x5lcfd/ff676893f6d5bf5c0765 to your computer and use it in GitHub Desktop.
Save x5lcfd/ff676893f6d5bf5c0765 to your computer and use it in GitHub Desktop.
update usage
IEnumerator Waiting(TimeSpan elapsedTimeSpan,
System.Action<TimeSpan> timeCallback,
System.Action callback)
{
for (;elapsedTimeSpan.CompareTo(TimeSpan.Zero) >= 0;)
{
if (timeCallback != null) { timeCallback(elapsedTimeSpan); }
elapsedTimeSpan -= new TimeSpan(0, 0, 1);
yield return new WaitForSeconds(1.0f);
}
if (callback != null)
{
callback();
}
}
//Usage
//
//var cdCoroutine = cd.Waiting( new System.TimeSpan(0, 0, 10),
// elapsedTime =>
// {
// timeValue.text = string.Format( "{0:dd\\.hh\\:mm\\:ss}", elapsedTime );
// },
// null );
//
//StartCoroutine( cdCoroutine );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment