Game Development Reference
In-Depth Information
In the Inspector, expand the Label ➤ Normal property and change the text color to a different color
than what you used with the GUI Style in the previous example. In MonoDevelop, edit GUIScript
as follows:
#pragma strict
public var fadeDuration : float = 3;
var guiStyle : GUIStyle;
var myGuiSkin : GUISkin;
function OnGUI() {
GUI.skin = myGuiSkin;
...
GUI.Label(Rect(Screen.width/2 - 125, Screen.height/2 - 12.5, 250, 25), "Press C to
crouch or Space to jump", guiStyle);
}
Breaking this down:
(1) var guiStyle : GUIStyle;
guiStyle
1.
First, delete the code regarding the GUIStyle.
(2) var myGuiSkin : GUISkin;
Declare a reference variable myGuiSkin of type GUISkin.
2.
(3) GUI.skin = myGuiSkin;
3. Assign the customized myGuiSkin to be the active GUI.skin.
Save the script then select the GUI game object in Hierarchy. In the Inspector, you will see a Gui Skin
property has appeared in the GUIScript component. Drag the myGUISkin asset from the Project
panel Assets ➤ MyGUISkins folder and drop it into the Gui Skin field. Save the scene and playtest to
see the new text font color applied.
You can even mix and match GUI Styles and GUI Skins as needed. Getting the details just right is
important to the quality of the game. This section has provided an introduction to GUI controls and
how to customize them. Experiment away, and dig deeper into the Unity documentation for more
advanced tools and examples on how to apply them. Have fun!
Audio
Audio is tremendously important to the game experience and is used in a variety of ways to great
effect. The background music sets the mood, and can change throughout a game to reflect various
situations the player experiences, such as the difference between suspenseful music to indicate
impending danger versus the energetic music found in a fight scene.
 
 
Search WWH ::




Custom Search