using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TimerText : MonoBehaviour
{
///Way 2
int hour;
int minute;
int second;
int millisecond;
bool shouldCount = false;
public float timeSpent = 0.0f;
void onEnable()
{
shouldCount = true;
}
void Update()
{
if (shouldCount)
{
timeSpent += Time.deltaTime;
//hour = (int)timeSpent / 3600;
// minute = ((int)timeSpent - (int)timeSpent / 3600 * 3600) / 60;
second = (int)timeSpent - (int)timeSpent / 3600 * 3600 - ((int)timeSpent - (int)timeSpent / 3600 * 3600) / 60 * 60;
millisecond = (int)((timeSpent - (int)timeSpent) * 1000);
//text_timeSpent.text = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", hour, minute, second, millisecond);
GetComponent().text = string.Format("{0:D2}.{1:D3}", second, millisecond);
}
}
//void onDestroy
void onDisable()
{
shouldCount = false;
GetComponent().text = "";
}
}