Unity Freebies: Game Timer, Cinematic Letterbox, and Fade-in Scripts

November 14, 2012 — Leave a comment

Two awesome Unity behavior scripts that you can download and use for free right now!

GUIGameTimerAndGUILetterbox.zip (3 KB ZIP)

The GUI Gamer Timer runs a timer during the life of your game.  You can display the timer on the screen or simply have it running behind the scenes so that you can determine the elapsed minutes and seconds from other scripts in the game.

The GUI Letterbox script draws a cinematic letterbox on the screen which can open up to expose the full view of your game at the time you specify. Along with some good music, this can help you set a very interesting mood! The letterbox script also contains fade-in functionality which you can use alone or in combination with the letterbox.

(Click to enlarge…)

Create a new GameObject and name it ‘GameController’. Drag both scripts onto a GameObject that’s in the scene. Select the GameObject that holds the script and then look in the Inspector panel.

Following is a definition of each attribute that you can change in the inspector:

GUI Game Timer

  • Position X – Specifies where to draw the timer from the left-hand side of the screen.
  • Position Y – Specifies where to start drawing the timer from the top-most side of the screen.
  • Gui Depth – Specifies the depth to render the timer on the GUI plane. A lower number, such as zero can help ensure the timer draws atop any other GUI you might be rendering.
  • Show Time – Specifies whether or not to show the timer on screen. If the behavior is active, the timer will still be running whether it’s shown on screen or not. This will allow you to access the timer from other scripts  and call the script’s getMinutes() and getSeconds() methods to determine elapsed time.

GUI Letterbox

  • Use Letterbox – Specifies whether or not to use the letterbox feature.
  • Use Fade In – Specifies whether or not to use the fade-in feature.
  • Black Solid Texture – You need to drag and drop the included blackSolid.gif file on this property in the inspector!
  • Start Fade In Minutes – When, in minutes, to start fading in from black (can be zero to use seconds only)
  • Start Fade In Seconds – When, in seconds, to start fading in from black (combines with minutes if minutes is set greater than zero).
  • Start Open Letterbox Minutes – When, in minutes, to start opening the cinematic letterbox (can be zero to use seconds only)
  • Start Open Letterbox Seconds – When, in seconds, to start opening the cinematic letterbox (combines with minutes if minutes is set greater than zero).

If you like these free goodies, please give us a +1, Tweet and share with your friends!

ethan.york

Posts

Write for us!

We pay for great content that helps young and aspiring game makers along the path to mastery. You can earn extra income doing what you love and sharing what you learn! For more information, contact info@mastergamecraft.com.

No Comments

Be the first to start the conversation.

Leave a Reply