Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Timer : MonoBehaviour
{
public static Timer instance;
public TextMeshProUGUI TimerText;
private float startTime;
private void Start()
{
instance = this;
startTime = Time.time;
}
private void Update()
{
float time = Time.time - startTime;
string minutes = ((int)time / 60).ToString();
string seconds = (time % 60).ToString("f0");
TimerText.text = minutes + ":" + seconds;
}
}
I tried quite a few things and none of them worked. I'm kind of new to C# and unity and I would like to know how to stop this timer from another script. And I want to check if the game object the script is on is enabled.
Any help is appreciated :)