Graphics Reference
In-Depth Information
void Init()
{
LoadHighScore();
HideMessages ();
Invoke("ShowGetReady",1);
Invoke("HideMessages",2);
}
public void HideMessages()
{
gameOverMessage.SetActive(false);
getReadyMessage.SetActive(false);
}
public void ShowGetReady()
{
getReadyMessage.SetActive(true);
}
public void ShowGameOver()
{
SaveHighScore();
// show the game over message
gameOverMessage.SetActive(true);
}
void OnGUI()
{
GUI.Label(new Rect (10,10,100,50),"PLAYER 1");
GUI.Label(new Rect (10,40,100,50),"SCORE "+player_score);
GUI.Label(new Rect (10,70,200,50),"HIGH SCORE "+player_
highscore);
GUI.Label(new Rect (10,100,100,50),"LIVES "+player_lives);
}
}
11.11.1 Script Breakdown
The script derives from BaseUIDataManager, the standard UI script shown in Chapter
10. The BaseUIDataManager declares several common variables and provides some basic
functions to deal with them:
using UnityEngine;
using System.Collections;
public class UI_LBS : BaseUIDataManager
{
In the example games, the game-over message and get-ready messages are GUITexture
objects. In the Unity editor Inspector window, the gameOverMessage and getReadyMessage
variables are set to their objects in the scene:
Search WWH ::




Custom Search