Game Development Reference
In-Depth Information
7. Observe that as you click on the populated references inside
Level2Ex-
tras
, Unity highlights the GameObject instances with a unique yellow border
so that you can quickly find the actual object instances that are connected in
the hierarchy.
8. Now that
Level2Extras
has been properly configured, create another
script named
Level2Init
, and add an instance of it to the
_level2
GameObject.
9. The
level2Init
script will use the
Level2Extras
script as an interface to
find specific GameObjects and connect them into the appropriate level 2 pop
ups. This needs to happen since the pop ups are global; they cannot pre-
serve references to objects that are dynamically loaded from later levels.
10. In the
start()
method of
Level2Init
, the script attempts to locate the
Player
GameObject, named as either
Player
or
Player1
:
GameObject playerObj = GameObject.Find
("Player1");
if (playerObj == null)
playerObj = GameObject.Find ("Player");