纳金网

标题: unity3d倒计时c#代码 [打印本页]

作者: 狂风大尉    时间: 2015-2-28 23:35
标题: unity3d倒计时c#代码

unity3d倒计时c#代码
  1. using UnityEngine;

  2. using System.Collections;

  3. using System;

  4. public class textTest : MonoBehaviour {

  5. public UILabel countDown;

  6. public int endTime;

  7. public int currentTime;

  8. public int startTime;

  9. public int second;

  10. public int minute;

  11. private string printTime;

  12. private string stringEndTime;

  13. void Start () {

  14. // startTime = 240;  //4分钟倒计时

  15. startTime = 0;  //从零开始计时

  16. }

  17. void Update () {

  18. // endTime = startTime - currentTime; //倒计时

  19. endTime = startTime + currentTime;

  20. second = endTime % 60;

  21. minute = endTime / 60;

  22. currentTime = Mathf.CeilToInt(Time.fixedTime);

  23. if(second<10)

  24. {printTime = “:0”;

  25. }else{printTime = “:”;}

  26. stringEndTime = “00:0” + minute + printTime + second;

  27. //print (“00:0” + minute + printTime + second);

  28. print(stringEndTime);

  29. countDown.text = stringEndTime;

  30. if(endTime<0)

  31. {endTime = 0;}

  32. //currentTime.text = DateTime.Now.ToString(“hh:mm:ss”);

  33. }

  34. }
复制代码

作者: 刘帅朋    时间: 2017-11-9 14:33
谢谢分享,谢谢




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5