- Home /
Question by
jumpman8947 · Jul 22, 2016 at 08:49 AM ·
guitimer-script
Timer Start on Gui from function
In my Unity Editor i have within my canvas a time remaining input field(TimeRemaining). What i'm trying to do is when the game starts have this countdown automatically, and display the time remaining in the textfield. In my countDown class i have the following code:
public class countDown : MonoBehaviour {
float timeRemaining = 5;
public void RunClock()
{
timeRemaining -= Time.deltaTime;
if (timeRemaining > 0)
{
// This is where i guess I would need to connect the timeRemaining and the textfield component.
}
else
{
// Do something to end the game
}
}
}
Connected to the TimeRemaining Inputfield, i have an object connected as a component. And within that object it holds the script for the above.
The game gets started from another script where i call the Start() function.
Comment