Game Development Reference
In-Depth Information
component to levelLoad , which then performs the Applica-
tion.LoadLevelAdditive call.
25. The case for Instantiate will dereference the GameObj object in the
popupData sideData member, and perform a GameOb-
ject.Instantiate call on it to duplicate that Prefab. It will then set the
parent to the GameObject that has the name 'name' from the sideData
field. Lastly, it will set the position and orientation to post and rotation of the
Prefab after it is initialized (the pos and rot values of the Prefab at the time
it is created).
26. The HideObject and ShowObject actions will set the object referenced by
the sideData to either active =true or active=false . This has the
effect of disabling or enabling the renderer as well as the rest of the game
logic/components on this object.
27. The self-destruct method will call Destroy() on the parent object of the but-
ton. This has the effect of destroying the pop up and all the children buttons
and such. Of course, this assumes that buttons are a 1-layer child of the main
pop-up root! Whether you decide to destroy or hide an object, it will depend
on the specific needs of your game. Destroying an object will of course free
up more memory; however, this should be done for every frame. If a light-
weight way to hide and unhide an object is required, consider just disabling
and enabling the renderer with HideObject and ShowObject .
Congratulations! We have an implemented popupButtonScript attached to our
NEW button. Let's configure it:
1. On the NEW button, open up the popupButtonScript and set the number
of actions to 2 (by manually setting size = 2 ). This will correspond to two
actions that will be invoked, one at a time, on mouse click.
2. Set the action of Element 0 to be LoadLevel1 . Open up the Data field as-
sociated with this action and set the name to LEVEL1 (to match the scene
file name).
3. For Element 1 , set the action to SelfDestruct . By putting this second,
we guarantee the button will load the new level and then destroy the pop up
(which is what we want!).
4. Set the On texture to a light blue-colored texture and the Off texture to a
dark blue variation. Set the ButtonState to Off by default.
Search WWH ::




Custom Search