I’m trying to keep accelerated time in a TMP_Text text box. I want to multiply my real time by 8. The printed timespan t is always correct, but the timerText lags behind to the last time it was active (it doesn’t keep time in the background when it is .SetActive(false) - how do I do this correctly? The Update() code is outside of the TMP_Text GameObject, it’s in a Singleton. Any help would be very much appreciated!
private float timer;
private float gameTime;
public TMP_Text timerText;
void Update()
{
timer = Time.realtimeSinceStartup;
print("Real time since startup" + timer);
gameTime = timer * 8;
print("Game Time = " + gameTime);
System.TimeSpan t = System.TimeSpan.FromSeconds(gameTime);
print("time span = " + t);
timerText.text = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds, t.Milliseconds);
}