// Start is called before the first frame update void Start() { textmeshPro = GetComponent <TextMeshProUGUI>(); textmeshPro.text = timer.ToString(); objectivesTrackerObject = GameObject.Find("ObjectivesTracker"); objectivesTracker = objectivesTrackerObject.GetComponent <ObjectivesTracker>(); timer = objectivesTracker.getElapsedTime(); }
// Update is called once per frame void Update() { timer = objectivesTracker.getElapsedTime(); int seconds; double miliseconds; minutes = (int)objectivesTracker.getElapsedTime() / 60; seconds = (int)(timer) - (minutes * 60); miliseconds = (timer - seconds - minutes * 60) * 100; if (minutes < 10) { textmeshPro.text = "0" + minutes.ToString(); } else { textmeshPro.text = minutes.ToString(); } if (seconds < 10) { textmeshPro.text += " : 0" + seconds.ToString(); } else { textmeshPro.text += " : " + seconds.ToString(); } if (miliseconds < 10) { textmeshPro.text += " : 0" + miliseconds.ToString("f0"); } else { textmeshPro.text += " : " + miliseconds.ToString("f0"); } }