- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
  
- 纳金币
- 38279
- 精华
- 111
|
unity3d倒计时c#代码- using UnityEngine;
-
- using System.Collections;
-
- using System;
-
- public class textTest : MonoBehaviour {
-
- public UILabel countDown;
-
- public int endTime;
-
- public int currentTime;
-
- public int startTime;
-
- public int second;
-
- public int minute;
-
- private string printTime;
-
- private string stringEndTime;
-
- void Start () {
-
- // startTime = 240; //4分钟倒计时
-
- startTime = 0; //从零开始计时
-
- }
-
- void Update () {
-
- // endTime = startTime - currentTime; //倒计时
-
- endTime = startTime + currentTime;
-
- second = endTime % 60;
-
- minute = endTime / 60;
-
- currentTime = Mathf.CeilToInt(Time.fixedTime);
-
- if(second<10)
-
- {printTime = “:0”;
-
- }else{printTime = “:”;}
-
- stringEndTime = “00:0” + minute + printTime + second;
-
- //print (“00:0” + minute + printTime + second);
-
- print(stringEndTime);
-
- countDown.text = stringEndTime;
-
- if(endTime<0)
-
- {endTime = 0;}
-
- //currentTime.text = DateTime.Now.ToString(“hh:mm:ss”);
-
- }
-
- }
复制代码 |
|