Game Development Reference
In-Depth Information
PopupButtonScript pbs =
ppm.Level2Start.transform.FindChild
("Button1").gameObject.GetComponent<PopupButtonScript>();
15. We also store a reference to the Level2Extras script for easy access later
in the method:
Level2Extras l2x =
GetComponent<Level2Extras>();
16. If the Level2Extras component can be found, we need to associate
setupLevel2 to the popup_Level2Start instance on its first button ac-
tion. Then, we associate raceStartup to the popup_Level2Start in-
stance on its second button action:
pbs.actions[0].data.obj = l2x.setupLevel2;
pbs.actions[1].data.obj = l2x.raceStartup;
17. Next, we try to cache a reference to the re-
sponse_ShowRaceResultsPopup component that is attached to
LevelLogicObj inside Level2Extras :
response_ShowRaceResultsPopup rrp =
l2x.LevelLogicObj.GetComponent<response_ShowRaceResultsPopup>();
18. If the race results pop-up component can be found, we connect the player ,
GameMgr , PassPopup , and FailPopup to this script. This will allow this re-
sponse script to operate correctly during the race:
rrp.player = GameObject.Find ("Player1");
rrp.gm = GameObject.Find
("Game").GetComponent<gameMgr>();
rrp.passPopup = ppm.Level2Finish;
rrp.retryPopup = ppm.Level2Repeat;
19. After this, the Level2Init script will destroy itself. This stops the init logic
from running more than once when _level2 is loaded. If _level2 is ever
Search WWH ::




Custom Search