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) ...

Get Unity 3D Game Development by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.