Game Development Reference
In-Depth Information
Figure 10-16. The Comic Sans font
With the GUI in place, it's time to add the code for the buttons. Both calls are very simple.
1.
Open the EndGameGUI script.
2.
In the Play Again button's conditional, add
Application.LoadLevel("GardenLevel1");
3.
In the Quit button's conditional, add
Application.Quit();
4. Save the script.
While the code is simple for both, there are a few caveats. Application.Quit() won't stop the
application when you are running it through the editor. To see if it works, you will have to do a build.
Application.LoadLevel also requires the level to have been added to the build before it can be
found. You can call a level either by name or by its build index number.
5.
Save the scene, and save the project.
6.
From the File menu, open Build Settings.
7.
Click the Add Current button to add GardenLevel1 to the build.
 
Search WWH ::




Custom Search