unity3d游戏开发 —— 倒计时

using UnityEngine;
using System.Collections;

public class CoolTime : MonoBehaviour {
// Use this for initialization
void Start () {
}
int CoolTimes = 100;
// Update is called once per frame
void Update () {

}
void OnGUI()
{
GUILayout.Label(CoolTimes.ToString());
if (GUILayout.Button("Begin"))
{
StartCoroutine(waitForOneSecond());
}
}

public IEnumerator waitForOneSecond()
{
while (CoolTimes >= 0)
{
CoolTimes--;
yield return new WaitForSeconds(1);
}
}
}

posted @ 2014-07-24 11:17  Zhaoyier  阅读(253)  评论(0编辑  收藏  举报