Hey,
Just wondering how do you create a script that constantly counts up in game, with Millisecond precision.
The timer must be able to continue after the scene is reloaded, or another scene with the timer.
Example:
“01:34:87”
Thanks.
Hey,
Just wondering how do you create a script that constantly counts up in game, with Millisecond precision.
The timer must be able to continue after the scene is reloaded, or another scene with the timer.
Example:
“01:34:87”
Thanks.
@JacksonBurrell1
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
public class timer : MonoBehaviour
{
public Text timerLabel;
public float time;
void Update() {
time += Time.deltaTime;
var minutes = Mathf.Floor(time / 60); //Divide the guiTime by sixty to get the minutes.
var seconds = time % 60;//Use the euclidean division for the seconds.
var fraction = (time * 100) % 100;
//update the label value
timerLabel.text = string.Format ("{0:00} : {1:00} : {2:00}", minutes, seconds, fraction);
}
},@JacksonBurrell1
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
public class timer : MonoBehaviour
{
public Text timerLabel;
public float time;
void Update() {
time += Time.deltaTime;
var minutes = Mathf.Floor(time / 60); //Divide the guiTime by sixty to get the minutes.
var seconds = time % 60;//Use the euclidean division for the seconds.
var fraction = (time * 100) % 100;
//update the label value
timerLabel.text = string.Format ("{0:00} : {1:00} : {2:00}", minutes, seconds, fraction);
}
},
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
public class timer : MonoBehaviour
{
public Text timerLabel;
public float time;
void Update() {
time += Time.deltaTime;
var minutes = Mathf.Floor(time / 60); //Divide the guiTime by sixty to get the minutes.
var seconds = time % 60;//Use the euclidean division for the seconds.
var fraction = (time * 100) % 100;
//update the label value
timerLabel.text = string.Format ("{0:00} : {1:00} : {2:00}", minutes, seconds, fraction);
}
}