标签:start down unity gui imm cond end private class
using UnityEngine;
using System.Collections;
using System;
public class Timmer : MonoBehaviour {
public GameObject countDown;
public int endTime;
public GUIText UI_Time;
public int currentTime;
public int startTime;
public int second;
public int minute;
private string printTime;
private string stringEndTime;
void Start () {
startTime = 3;
}
void Update () {
endTime = startTime - currentTime;
second = endTime % 60;
minute = endTime / 60;
currentTime = Mathf.CeilToInt(Time.fixedTime); //开始计时
if(second<10)
{printTime = ":0";
}else{printTime = ":";}
stringEndTime = minute + printTime + second;
print ( printTime + second);
print(stringEndTime);
UI_Time.text = stringEndTime; //显示到游戏场景中
//倒计时完毕游戏结束
if(endTime<0)
{
second = 0;
minute = 0;
stringEndTime = minute + printTime + second; //
UI_Time.text = stringEndTime;
GameManager._instance.GameOver(); //跳转到游戏结束场景
}
}
}
标签:start down unity gui imm cond end private class
原文地址:http://www.cnblogs.com/jiangyuzhen/p/6518725.html