I have done everything to try to display my count down timer on the screen. However, I cannot setup the gui parameter as a variable because it keeps throwing a Null exception error. Therefore, I need to know if I have to set a varaible in my ShowTime function or use public at the begging of the program so it can be access anywhere from the code.
This is the error message.
Unknown identifier: ‘gui’.
var startTime : float;
var timeRemaining : float;
function Start () {
guiText.material.color = Color.white;
startTime = 120.0;
}
function Update () {
if(!isPaused)
{
DoCountdown();
}
}
function DoCountdown()
{
isPaused=true;
timeRemaining = startTime - Time.time;
ShowTime();
}
function UnpauseClock()
{
isPaused = false;
}
function ShowTime()
{
var minutes : int;
var seconds : int;
var timeStr : String;
minutes = timeRemaining/60;
seconds = timeRemaining%60;
timeStr = minutes.ToString() + ":";
timeStr += seconds.ToString("D2");
gui.Text.text = timeStr;
}
function TimeIsUp()
{
if(timeRemaining < 0)
{
timeRemaining = 0;
isPaused = true;
TimeIsUp();
}
Debug.Log("Time is up");
}