- Home /
NGUI countdown in label
Hello again, Im trying to get a countdown C# script to appear at each second (preferably with miliseconds too) inside of an NGUI label. my label is named CountDown and here is the code i have so far (i havent even tried to implement miliseconds yet, im just doing seconds and minutes till i can get it figured out)
using UnityEngine;
using System.Collections;
public class Countdown : MonoBehaviour {
UILabel c = GameObject.Find("CountDown").GetComponent<UILabel>();
public float Seconds = 30;
public float Minutes = 2;
string textTime = "";
// Update is called once per frame
void Update () {
if(Seconds <= 0)
{
Seconds = 59;
if(Minutes >= 1)
{
Minutes = (Minutes - 1);
}
else
{
Minutes = 0;
Seconds = 0;
}
}
else
{
Seconds -= Time.deltaTime;
}
textTime = Minutes + " : " + Seconds + " : ";
c.text = textTime;
}
}
the NGUI label is pretty much just remaining completely blank though. im sure what im doing wrong is small and inane but i cant seem to put my finger on it. does anyone have any ideas?
Comment