/// <summary> /// Starts a timer, and calls the callback when its over /// </summary> /// <param name="time">time before the callback should be called.</param> /// <param name="callback">callback to be called when timer is over.</param> /// <returns></returns> public Coroutine StartTimer(float time, TimerOver callback) { if (time <= 0) { Debug.LogError("Timer is set to 0."); } if (callback == null) { Debug.LogError("Callback is null"); } return(StartCoroutine(_startTimer(time, callback))); }
private IEnumerator _startTimer(float time, TimerOver callback) { yield return(new WaitForSeconds(time)); callback(); }