Skip to content
Permalink
2077f72d03
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
56 lines (49 sloc) 1.13 KB
using UnityEngine;
using System.Collections;
#region Not Used ATM
public class Timer : MonoBehaviour {
private float startTime;
private float restSeconds;
private int roundedRestSeconds;
private float displaySeconds;
private float displayMinutes;
public int CountDownSeconds=120;
private float TimePassed;
string timetext;
/* Found at:
* http://answers.unity3d.com/questions/11939/count-down-timer.html
*/
// Use this for initialization
void Start ()
{
startTime=Time.deltaTime;
}
void OnGUI()
{
TimePassed= Time.time-startTime;
restSeconds = CountDownSeconds-TimePassed;
roundedRestSeconds=Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = (roundedRestSeconds / 60)%60;
timetext = (displayMinutes.ToString()+":");
if (displaySeconds > 9)
{
timetext = timetext + displaySeconds.ToString();
}
else
{
timetext = timetext + "0" + displaySeconds.ToString();
}
GUI.Label(new Rect(20,50,100,50), timetext);
if( TimePassed >= CountDownSeconds)
{
TimePassed = 0;
startTime = Time.deltaTime;
Debug.Log("time's up");
}
}
void Update()
{
}
}
#endregion