Game Development Reference
In-Depth Information
Figure 10-29. The Unity GUI buttons in the Start menu
The math involved here is nothing fancy. Obviously you could code button sizes to be affected by
the screen size, but for testing during the authoring process, this will get the job done. Feel free to
improve the logic and equations that control the button placement. Also, if you decide not to allow
the player to resize the game window during run time, you could move the screen height and width
assignments into the Start function to conserve resources.
Adding the New Level to the Build
With the visual aspects of the start screen sorted out, you can add the new level to the build.
1.
Stop Play mode, and save the StartMenu scene.
2.
Open Build Settings from the Files menu.
3.
Click the Add Current button.
The Start menu is added to the build, but its index number is 1. For it to be the first scene shown,
it will have to be index 0.
4.
Click on the GardenLevel1 scene, and drag it below the StartMenu scene.
The StartMenu is now index 0.
5.
Click Build and Run, and overwrite GardenTest.
6.
Play the game, and make sure the GardenLevel1 (now index 1) loads from
the Play Game button.
There's one thing you may have noticed that is inconsistent with a shooter-type game. The cursor
is visible throughout the game. You can suppress it during regular game play and bring it back
whenever the GUI controls are active. This code can be on any script, but it will be easy to find and
turn back on from the OnGUI functions.
 
Search WWH ::




Custom Search