Game Development Reference
In-Depth Information
three in our final build, let's add them so that they are available for conveni-
ence.
Congratulations! Now these new scenes will be accessible to the game. Let's con-
nect the new level one scene to the main scene file with a simple pop up.
Creating the PopupMainMenu GameObject
A great game requires an interesting and usable user interface system. Our game
will require a number of pop-up windows that will be used to communicate to the
user. The user will also be able to interact with the game by selecting buttons on pop
ups. The first pop up we need to create is the one that starts the game on the main
menu.
A number of middleware technologies exist to help the Unity developer create active
UI systems quickly and with high quality; at the time of writing this topic, NGUI and
EGUI are pop-up systems available on the Unity asset store for this very purpose.
While it is possible to use any one of these or other extensions to build your UI,
we will develop our own from scratch. Let's create a start screen from which we will
launch level one by performing the following steps:
1. Switch to the MAIN scene file.
2. Create a plane, and parent it to MainCamera . This will serve as the back-
ground to our pop-up window panel.
3. Set its position to ( 0 , 0 , 0 ), and orient it towards the camera. Translate it
along its z axis so that it is forward from the camera by 9 units.
4. Scale the plane by 1.5 on the x axis, and rotate it to 270 degrees around the
x axis. At this point, the plane should move with the camera and occlude its
line of sight to the rest of the scene. Now, by enabling this GameObject, we
have a fullscreen backdrop for menus. Name this plane PopupMainMenu .
5. Create a new, colored material, and apply it to the plane. In our example, I
selected the green color.
6. Create a 3D text object. Notice that the component is named TextMesh .
This will be used to communicate with the user in our simple menu page.
Parent it to PopupMainMenu . Set its relative position to ( -3.3 , 0.8 , 2.9 ) so
that it is near the top and centered. Set its scale to ( 0.6 , 1 , 1 ), and apply a
90 degree rotation to the x axis so that it is nicely centered at the top of the
screen.
Search WWH ::




Custom Search