fgm24/Assets/Scripts/UI/SurvivalTimer.cs

28 lines
681 B
C#
Raw Normal View History

2024-02-04 07:54:34 +01:00
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);
2024-02-04 10:04:07 +01:00
GameManager.Instance.setTime(timerText.text);
2024-02-04 07:54:34 +01:00
}
}