Game Development Reference
In-Depth Information
Listing 6.16 Adding a Health Value to the GUI
. . .
var theWrench: GameObject;
var health: int = 100;
var healthStyle: GUIStyle;
function OnGUI ()
{
. . .
GUI.Box (Rect (3,3,75,75),"Health");
GUI.Label (Rect (3,10,75,75),health.ToString(),
healthStyle);
if(health > 75)
GUI.Box (Rect (83,3,75,75),healthOk);
else if(health > 30)
. . .
Step 40. Note that the health value is using its own custom GUIStyle.
This style sets the font, font color, and font alignment. Settings
for healthStyle can be modified in the Inspector view for the Main
Camera as shown in Figure 6.13 .
FIG 6.13 Setting custom GUI item font, color, and alignment.
Search Nedrilad ::




Custom Search