int second= 0;
int minute = 0;
int hour = 0;
float timer = 0;
string timerStr = string.Empty;
void SimpleTimer(){
timer += Time.deltaTime;
if(timer >= 1f){ second++; timer = 0;}
if(second >= 60f){ minute++; second = 0;}
if(minute >= 60f){hour++; minute= 0;}
if(hour >= 24f){hour = 0; }
timerStr = string.Format("{0:D2}:{1:D2}:{2:D2}",hour,minute,second);
print(timerStr);
}
简单计时器代码
最新推荐文章于 2024-09-11 22:45:35 发布