Game Development Reference
In-Depth Information
}
//Draw a 45 degree black shadow text by shifting 2 pixel bottom-
right
public function DrawShadowText (position : Rect, text : String,
style : GUIStyle, textColor : Color) : void {
var backupStyle : GUIStyle = style;
//Draw a Shadow Text
style.normal.textColor = Color.black;
//Shift 2 pixel left and 2 pixel bottom
position.x += pixelShift;
position.y += pixelShift;
GUI.Label(position, text, style);
/////////////////////////////////////////////
//Draw a Text
style.normal.textColor = textColor;
//Shift pixel back
position.x -= pixelShift;
position.y -= pixelShift;
GUI.Label(position, text, style);
style = backupStyle; // Set style back
}
2. Now, go back to Unity editor. Create the new
GUISkin
by going to
Assets
|
Create
|
GUI Skin
and name it
CustomSkin
; then click to bring up its
Inspector
view and set
the following:
F
Font
:
Federation
(Drag the
Federation
font in
Chapter5/Fonts
folder
here)
F
Custom Styles
F
Size
:
1
F
Element 0
:
Name
:
RocketText
Normal
Text Color
:
R: 255
,
G: 255
,
B: 255
,
A: 255
Font
:
Federation
Font Size
:
20
Font Style
:
Bold
Other than the parameters menioned earlier, we will leave everything as default.