Unity使用Time类手写一个时钟计时器

匿名 (未验证) 提交于 2019-12-03 00:22:01
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;}         if (s >= 60) {m++;s = 0;}                                            if (m >= 60) {h++;m = 0;}         if (h >= 99) {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);     }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!