Game Development Reference
In-Depth Information
Customizing Controls
Game design addresses both the function and look of your game. So far you've dealt with the
function and placement of GUI controls, but you will also want to customize the appearance of the
controls for your game. This is where GUI Styles and GUI Skins come in.
GUI Styles
Use a GUI Style to change the look of a single control. Open GUIScript in Monodevelop and add the
following line of code:
public var fadeDuration : float = 3;
var guiStyle : GUIStyle;
Save the script. In the Unity editor, with the GUI game object selected you will see the Gui Style
property appear in the GUIScript script component in the Inspector. Expand Custom Gui Style to
show the custom attributes. You can enter a name for this Style in the Name field. Expand Normal to
show the Background and Text Color attributes (Figure 11-5 ).
Figure 11-5. Custom Gui Style property in the GUIScript script component in the Inspector
Choose a new Text Color. For the Style to be applied to the fading label, you will have to edit
GUIScript and pass in the guiStyle argument to GUI.Label as follows:
GUI.Label(Rect(Screen.width/2 - 125, Screen.height/2 - 12.5, 250, 25), "Press C to crouch or Space
to jump", guiStyle);
Save the script and play. This time the instructions for the player in the GUI label will appear in the
new text color.
 
Search WWH ::




Custom Search