Skip to content

Instantly share code, notes, and snippets.

@WakkyFree
Last active April 3, 2018 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WakkyFree/bac46e19599dbd73790d2b4afd5bd10d to your computer and use it in GitHub Desktop.
Save WakkyFree/bac46e19599dbd73790d2b4afd5bd10d to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class CountDownTimer : MonoBehaviour {
public static int gameTimerInt;
private float gameTimerFloat;
public Text timeText;
// Use this for initialization
void Start () {
gameTimerFloat = 60.0f;
gameTimerInt = (int) gameTimerFloat;
timeText.text = "" + gameTimerInt.ToString();
}
// Update is called once per frame
void Update () {
if(gameTimerFloat > 0.0f){
gameTimerFloat -= Time.deltaTime;
gameTimerInt = (int) gameTimerFloat;
timeText.text = "" + gameTimerInt.ToString();
}
if(gameTimerFloat <= 0.0f){
gameTimerInt = 0;
timeText.text = "" + gameTimerInt.ToString();
}
}
}
if(gameTimerFloat <= 0.0f){
gameTimerInt = 0;
timeText.text = "" + gameTimerInt.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment