예제 #1
0
 //Coroutine for incrementing timer over time
 private IEnumerator countDown(CountdownDelegate functionToExecute)
 {
     while (Time.realtimeSinceStartup < endTime)
     {
         print(endTime - Time.realtimeSinceStartup);
         yield return(new WaitForSeconds(updateInterval));
     }
     functionToExecute();
 }
예제 #2
0
 //Starts counting from 0
 public void countDownAndExecute(float duration, CountdownDelegate functionToExecute)
 {
     StopCoroutine(countDown(functionToExecute));
     endTime = duration + Time.realtimeSinceStartup;
     StartCoroutine(countDown(functionToExecute));
 }