public Text text1;
void Update()
{
Debug.Log("Time: " + (time * 0.001f).ToString("F1") + "s / " + (duration * 0.001f).ToString("F1") + "s");
//text1.text = ((duration-time) * 0.001f).ToString("F1");
float countDown = ((duration - time) * 0.001f);
if (countDown > 0)
{
countDown -= Time.deltaTime;
countDown = countDown < 0 ? 0 : countDown;
float minute = Mathf.Floor(countDown / 60);//轉成分鐘
float seconds = countDown % 60;//轉成秒
text1.text = minute.ToString("00") + ":" + seconds.ToString("00");
if (countDown <= 0)
{
Debug.Log("GameOver");
}
}
}
}
賦值即可