To edit the font that displays on our HUD, we add the following line of script to the Spongy.js
script at the very top of the script alongside the other variables:
Var myStyle: GUIStyle;
When we click on the Spongy GameObject, we should get the following in the Inspector:
When clicking on the My Style drop-down list, there are many sub-attributes that we can edit in order to create our own font style. For instance, we can change the timer's color from black to red by going to Normal | Text Color and selecting red.
We can also make the font bigger by setting the Font Size option to 20
.
To apply it to the timer so that the changes only affect the Timer HUD, we add myStyle
to the existing timer GUI.Box
that we have already created, as shown in the following script:
GUI.Box (Rect (10,10,100,30), "Time: "+Time.time, myStyle);