using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class timer: MonoBehaviour
{
public float timer = 3;//倒计时几秒
public GameObject t;//画布下的文本框
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (timer > 0)
{
timer -= Time.deltaTime;
t.GetComponent<Text>().text = timer.ToString("00");//这个意思是取整数的意思,如果想取小数那么就要ToString("0.0")
}
else GameOver();
}
void GameOver()
{
t.GetComponent<Text>().text = "Gameover";
}
}
倒计时
最新推荐文章于 2022-08-01 16:06:33 发布