Book Image

Learning Unity iOS Game Development

Book Image

Learning Unity iOS Game Development

Overview of this book

Table of Contents (14 chapters)
Learning Unity iOS Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
6
Main Menu, iAds, Leaderboards, Store Purchases, and Achievements
Index

Creating the game user interface


To begin with the user interface for our game, we need a class that manages when and how to use UI elements, such as buttons and when to show the UI screen.

The GameInfo class

In order for our other code classes to get a reference to the GameInfo class, we can create a GameObject in the scene that holds a GameInfo script component. To do this, perform the following steps:

  1. In the Assets/Scripts folder, right-click and select Create and then click on C# Script. Name this GameInfo.

  2. Double-click on the GameInfo script and select the Start function as Awake. Save this file and go back to Unity.

  3. Right-click on Hierarchy and select Create Empty. Name this new GameObject GameInfo.

  4. With this selected, search for Inspector and click on Add Component. Then, search for GameInfo and select GameInfo.

Importing UI images

We now need to import some PNG files to represent elements of the UI. These PNG images will represent elements such as buttons. To do this, perform the following...