Game Development Reference
In-Depth Information
5.
Open the script, and change the class declaration to match the new name:
public class CreditsGUI : MonoBehaviour {
6.
Change the Box control's text to “Credits.”
7.
Replace the rest of the current contents of the GUI Group with
int y = 240; // base Y position
int x = 150; // base x inset
int yOffset = 60; // y offset
// title
GUI.Label(new Rect (x, y, 300, 60), "Game Design");
y+= yOffset;
// person
GUI.Label(new Rect (x, y, 300, 60), "your name here");
y+= yOffset;
// date
GUI.Label(new Rect (100, 370, 400, 40), "XXIV");
y+= yOffset;
// Main Menu
if (GUI.Button( new Rect (200,420,200,40), "Main Menu")) {
// Back to Main Menu
Application.LoadLevel("MainMenu");
}
8.
Save the script, and add it to the Credits object.
9.
Assign the Sub-Menu GUISkin as its New Skin.
10.
Click Play.
Besides being centered, the two label lines are on top of each other in the center. Ideally, you
would like one label to be right justified and one to be left justified. The last label, the date, is fine
as is. It turns out, you can both create your own templates, or GUI Styles, and you can use them to
selectively override those in the current GUISkin.
1.
Select the Sub-Menu GUISkin, and expand the Custom Styles section and the
Element 0 style.
2.
Set the Name to left_label .
3.
Change its Font Size to 20.
Its Alignment is already Upper Left.
4.
Increase the Custom Styles array Size to 2 .
 
Search WWH ::




Custom Search