计时器格式为(00:00:00Day0815)
using UnityEngine;
using System.Collections;
public classTest01: MonoBehaviour {
private float timer = 0f;
private int h = 0;
private int m = 0;
private int s = 0;
private string timeStr = string.Empty;
void Update ()
{
timer += Time.deltaTime;
if (timer >= 1f)
{s++;
timer = 0;
}
【计时器格式为(00:00:00Day0815)】if (s >= 60)
{m++;
s = 0;
}
if (m >= 60)
{h++;
m = 0;
}
if (h >= 24)
{h = 0;
}
}
void OnGUI()
{
timeStr = string.Format ("{0:D2}:{1:D2}:{2:D2}", h, m, s);
GUI.Label (new Rect (10, 10, 100, 200), timeStr);
}
}
推荐阅读
- 为什么你的路演总会超时()
- 知识
- 财商智慧课(六)
- 低头思故乡——只是因为睡不着
- 华为旁!大社区、地铁新盘,佳兆业城市广场五期!
- 吃了早餐,反而容易饿(为什么?)
- 你有婚内虐待行为吗()
- Android中的AES加密-下
- ?【段子图】内裤为啥湿呢(想想好邪恶啊...)
- 孩子行为背后的秘密(2)胡老师讲座感悟