Files
DeviantMobile-Rohan/Assets/New Lowpoly Models/Scripts/TimerNew.cs
2026-06-26 22:41:39 +05:30

22 lines
482 B
C#

using TMPro;
using UnityEngine;
public class TimerNew : MonoBehaviour
{
public TextMeshProUGUI timerText;
public float time = 120f; // 2 minutes
void Update()
{
if (time > 0)
{
time -= Time.deltaTime;
time = Mathf.Max(time, 0);
}
int minutes = Mathf.FloorToInt(time / 60);
int seconds = Mathf.FloorToInt(time % 60);
timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
}
}