Game Development Reference
In-Depth Information
Testing our work
Let's trace through how the pop-up system works. When the main scene first loads,
the popup_MainMenu Prefab renders in front of the camera. It does this because it is
parented to the main camera's transform as a child object. This means that no matter
what position and orientation the camera has, the pop up will move relative to this and
always be on the screen, effectively in screen coordinates. This is a common trick in
game programming used to achieve quasi-2D screen space results with 3D objects.
When the New button is clicked, the popupButtonScript iterates over the action
array, and based on the enumeration for the action, it dispatches an appropriate com-
mand. For now, we set the GameState to loading level1 and let the gameMan-
ager script handle the loading of the new scene file. We then call SelfDestruct
to delete the MainMenu object from the world (we won't need it anymore as we are
in-game).
When the Info button is clicked, the popupButtonScript iterates over the action
array, dispatching commands based on the value of the action enumeration. The first
thing that happens is that popup_Info is instantiated and parented to the camera.
Since this pop up has the same position and orientation as popup_MainMenu , the
transition appears seamless! Then, popup_MainMenu is destroyed that leaves only
the Information dialog displayed.
If the Return button on the popup_Info dialog is pressed, it iterates over its actions
and invokes two commands. It instantiates popup_MainMenu again (from the Prefab
in the Project window so that it is a new instance of the menu and not the original),
then it calls selfDestructs and deletes the popup_Info window, leaving only the
main menu. Since they share the same transform, the transition appears seamless.
If the Quit button is pressed, the application terminates. This is not readily apparent
in the editor, but once we build to execute, this will terminate the program.
Search WWH ::




Custom Search