2
我要把它改变的.text以下格式:Unity3D C#计时器显示以毫秒为单位
00:00:00
而是我得到 0:00.00000 做什么,我需要更改以纠正我的代码?
private void Update()
{
if (!chestButton.IsInteractable())
{
if (IsChestReady()) {
chestButton.interactable = true;
chestTimer.SetActive (false);
chestTimerBg.SetActive (false);
newGift.SetActive (true);
return;
}
//Set Timer
ulong diff = ((ulong)DateTime.Now.Ticks - lastChestOpen);
ulong m = diff/TimeSpan.TicksPerMillisecond;
float secondsLeft = (float)(msToWait - m)/1000.0f;
string r = " ";
//Hours
r += ((int)secondsLeft/3600).ToString() + ": ";
secondsLeft -= ((int)secondsLeft/3600) * 3600;
//Minutes
r += ((int)secondsLeft/60).ToString();
//Seconds
r += (secondsLeft % 60).ToString();
chestTimerTxt.text = r;
}
}