fgm24/Assets/Scripts/UI/SurvivalTimer.cs

27 lines
627 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class SurvivalTimer : MonoBehaviour
{
[SerializeField] TextMeshProUGUI timerText;
float elapsedTime;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
elapsedTime += Time.deltaTime;
int minutes = Mathf.FloorToInt(elapsedTime / 60);
int seconds = Mathf.FloorToInt(elapsedTime % 60);
timerText.text = string.Format("{00:00}:{01:00}", minutes, seconds);
}
}