Game Development Reference
In-Depth Information
7. Note that the TextMesh component in the inspector is a container for the
3DText specific parameters. Set the text to the name of our game Geography
Quest.
8. Set the CharacterSize to 0.5 and the FontSize to 21 to make the title ap-
pear with an appealing size and shape. Just as one might do with a word
processor, set the font style to bold for extra visual impact.
9. Name this 3DText object textGeographyQuest to keep the hierarchy easy
to read and maintain.
10. Now, we need a prompt for the user to click to start. Let's duplicate the previ-
ous GameObject by clicking on it and pressing Ctr + D .
11. Rename this object textClickToContinue . Set the text field of the Tex-
tMesh on this object to New .
12. Move the GameObject to ( -1.8 , 0.9 , 1.2 ), and scale the font size down to
15 to place and scale the text appropriately.
13. Our menu is almost complete! Let's write a script to handle the mouse-click
event. Create a new script, and name it MainMenuScript . Attach this script
to the PopupMainMenu object.
14. This script will have two private member variables. One to store the main
Game GameObject (the one that holds the GameMgr and MissionMgr
classes) and one to hold the GameMgr script instance itself (attached to
Game ). We make these private because the object being referred to doesn't
need to change during the lifespan of the game, so finding it automatically
on startup is more robust. They can be configured as shown in the following
code:
private GameMgr gm;
Private GameObject GameObj;
15. Inside the Start() method, we will search for the object named Game . If it is
found, we store a reference to the GameMgr script instance attached to this
object as shown in the following code. Recall that the Start() method gets
invoked by the Unity engine for any class that inherits from MonoBehavior
the first time it runs after instantiation:
GameObj = GameObject.Find("Game");
if (GameObj)
{
Search WWH ::




Custom Search