Recall from Chapter 4, Mission One – Future Proofing the Code, that Unity3D supports the development of games that span multiple scene files. One benefit of splitting a game up into multiple scene files is that we (as programmers) can assign different lifespans to objects based on the scene file they belong to.
The MAIN
scene file is designed to not only be the entry point of our game, but it also contains the _global
GameObject. This GameObject acts as the parent of a hierarchy of objects that have persistent scope throughout the game. The following GameObjects should have global scope:
MainCamera
: This is the camera to which the scene will be renderedPlayer1
: This is the name of the GameObject that is the playable character or the hero of the gameScore
: This is aGUIText
element that displays the number of points the player has acquired so far
Every other GameObject will exist in one of the three scene files for the game—LEVEL1
, LEVEL2
, or LEVEL3
. Using the Application.LoadLevelAdditive...