Unity3D 简单的倒计时

 using System;
using UnityEngine;
using System.Collections; public class TimeCountdown : MonoBehaviour
{ //之前的一个时间点
public long startTime = ;
//限定时间秒
private long fixedTime = ;
private long nowTime; // Use this for initialization
void Start()
{
nowTime = (System.DateTime.Now.Ticks - System.DateTime.Parse("1970-01-01").Ticks) / ;
if (nowTime - startTime >= fixedTime)
{
Debug.Log("倒计时结束");
}
else
{
InvokeRepeating("CountDown", , );
}
} // Update is called once per frame
void Update()
{ } void CountDown()
{
fixedTime -= ;
gameObject.GetComponent<UILabel>().text = (fixedTime / ( * * )).ToString() + "天"
+ ((fixedTime/ - fixedTime / ( * * )**)/).ToString() + "小时"
+ ((fixedTime / ) % ).ToString() + "分"
+ (fixedTime % ).ToString() + "秒";
}
}

Unity3D  简单的倒计时

上一篇:隐藏技能go:linkname


下一篇:MFC注册窗口类以及FindWindow按窗口类名查询