How to create Count Down Timer in Unity
Notes:
How to create Count Down Timer in Unity:
using UnityEngine;
using UnityEngine.UI;
public class TimerController : MonoBehaviour {
Text timerText;
public int maxLevelPlayTime;
int timeLeft;
void Start () {
timerText = this.GetComponent<Text>();
timeLeft = maxLevelPlayTime;
timerText.text = "Time Left:" + timeLeft;
}
void Update () {
if (timeLeft > 0) {
timeLeft = (int)(maxLevelPlayTime - Time.timeSinceLevelLoad);
timerText.text = "Time Left:" + timeLeft;
}
}
}