Unity3D 编写游戏运行时间 格式为00:00:00
2017-07-14 11:13
176 查看
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameTime : MonoBehaviour { // Use this for initialization private Text text; private float timer = 0f; private int h = 0; private int m = 0; private int s = 0; private string timeStr = string.Empty; void Start() { text = GetComponent<Text>(); } // Update is called once per frame 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; } timeStr = string.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s); text.text = "" + timeStr; } }
相关文章推荐
- Unity3D中C#获取游戏时间并显示成秒表格式
- Unity3D中C#获取游戏时间并显示成秒表格式
- 时间字符串str转标准格式日期字符串str 00:00:00
- 0000-00-00时间格式
- 总结使用Unity3D优化游戏运行性能的经验
- 这个时间格式2017-09-26-T04:00:00Z php识别不出来
- java时间格式转化(毫秒 to 00:00)
- 总结使用Unity3D优化游戏运行性能的经验
- Unity3D中DateTime时间的各种字符串格式的转换
- 如果有时间,我有点想开发自己的数据库文件格式了,发现单机版游戏还没一种固定的数据库
- 使用Unity3D编写ARPG游戏——角色属性的定义与实现(一)
- 使用Unity3D编写ARPG游戏——角色属性的定义与实现(二)
- Unity3D之测试函数运行时间
- 时间格式 2016-08-15T16:00:00.000Z
- Unity3d帧率设置及在游戏运行时显示帧率
- java时间格式转化(毫秒 to 00:00)
- Python练习笔记——编写一个装饰器,测算出一个函数的运行时间
- 【UNITY3D 游戏开发之八】Unity编译到iPhone运行 Collider 无法正常触发事件解决方案
- 总结使用Unity3D优化游戏运行性能的经验
- C语言编写年月日格式时间转换为格林威治时间