/// <summary> /// 计时器 /// </summary> /// <param name="seconds"></param> /// <param name="timeout">时间结束的回调</param> /// <param name="timeUpdate">时间更新的回调</param> /// <returns></returns> public static IEnumerator Timer(float seconds, Action timeout, Action<float> timeUpdate) { float time = seconds; while (true) { if (time < 0) { timeout(); yield break; } else { timeUpdate(time); } time -= Time.deltaTime; yield return new WaitForFixedUpdate(); } }