Skip to content

Instantly share code, notes, and snippets.

@kazuooooo
Created January 2, 2015 07:09
Show Gist options
  • Save kazuooooo/4efab54947d93bf2ff97 to your computer and use it in GitHub Desktop.
Save kazuooooo/4efab54947d93bf2ff97 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class TimerGUIText : MonoBehaviour {
public float timer;
// Update is called once per frame
void Update () {
timer -= Time.deltaTime;
//小数点以下切り捨て(直接切り捨てるとうまくいかないので一旦表示用の別のfloat変数を用意)
float timerText = Mathf.Floor (timer);
guiText.text = "Time : " + timerText;
if (0.99f >= timer) {
//タイマーが終わったときの処理
guiText.text = "TIMEUP";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment