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 - grab the picture clock graphics

As per our agreement, all the pretty pictures are pre-drawn for you. Download the Unity assets package for this chapter. When you're ready to import it, click on Assets | Import Package… and find the .unitypackage file. Open it up, and thar she be! If only obtaining game graphics in a real production environment were this easy.

Let's get right to work by creating some code to make use of two of the graphics in the package a blue clock background bar, and a shiny yellow foreground bar that will slowly shrink as time marches on.

  1. Create a variable to store the elapsed time as a percentage:
    var isPaused : boolean = false; var startTime : float; //(in seconds) var timeRemaining : float; //(in seconds) ...

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