using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class BossWarning : MonoBehaviour { /// /// 对应的时间显示 /// public TextMeshProUGUI timeText; protected int lastIntSec = 0; protected float timeDisSec = 0; // Start is called before the first frame update void Start() { } /// /// 设置倒计时的时间. /// /// public void setCountDownTime( float cdtime) { timeDisSec = cdtime; lastIntSec = (int)Math.Ceiling(cdtime); timeText.text = lastIntSec.ToString() + "s"; } // Update is called once per frame void Update() { timeDisSec -= Time.deltaTime; int tint = (int)Math.Ceiling(timeDisSec); if (tint < 1) tint = 1; if( tint != lastIntSec) { lastIntSec = tint; timeText.text = lastIntSec.ToString() + "s"; } } }