using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class HegemonTime : MonoBehaviour { public Text timeText; public int timeNum; // Start is called before the first frame update void Start() { timeNum = 60; StartCoroutine(StartGame()); } private void Update() { } private IEnumerator StartGame() { while (timeNum >=0) { timeText.text = timeNum.ToString(); // 显示整数秒数 yield return new WaitForSeconds(1f); // 等待1秒 timeNum -= 1; } timeNum = 60; } }