O'Reilly logo

Unity 3D Game Development by Example by Ryan Henson Creighton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - prepare the clock code

Let's rough in a few empty functions and three variables that we'll need to make the clock work.

  1. Open up the clockScript by double-clicking it. Update the code:
    var isPaused : boolean = false;
    var startTime : float; //(in seconds)
    var timeRemaining : float; //(in seconds)
    function Start()
    {
    }
    function Update() {
    if (!isPaused)
    {
    // make sure the timer is not paused
    DoCountdown();
    }
    }
    function DoCountdown() {
    }
    function PauseClock()
    {
    isPaused = true;
    }
    function UnpauseClock()
    {
    isPaused = false;
    }
    function ShowTime()
    {
    }
    function TimeIsUp()
    {
    }
    
    

What just happened that's a whole lotta nothing

Here, we've created a list of functions that we'll probably need to get our clock working. The functions are empty, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required