First project upload
This commit is contained in:
22
Assets/New Lowpoly Models/Scripts/TimerNew.cs
Normal file
22
Assets/New Lowpoly Models/Scripts/TimerNew.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user