倒计时
public class CutDownLeftTime : MonoBehaviour { public void InitLeftTime(int leftTimeSeconds, EventMainType eventType) { if (leftTimeSeconds > 0) StartCoroutine(CutDownTime(leftTimeSeconds, eventType)); } float sceondUnit = 0; private IEnumerator CutDownTime(int leftTimeSeconds, EventMainType eventType) { while (true) { sceondUnit += Time.unscaledDeltaTime; if (sceondUnit >= 1) { leftTimeSeconds -= 1; GetComponent<UILabel>().text = new TimeSpan(0, 0, leftTimeSeconds).ToString(); sceondUnit = 0; if (leftTimeSeconds <= 0) { GameEvent evt = new GameEvent(); evt.EvtType = eventType; TGameCore.GetIntance().GetEventMgr().SendEvent(evt); yield break; } } yield return 0; } }