-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Creating E-Learning Games with Unity
By :
Having planned how to organize our GameObjects into globally persistent and level-specific lifespans, we must further update GameMgr.cs to ensure that only the current level is loaded at any time. To do this, perform the following steps:
In GameMgr.cs, inside the ChangeState() method, the first thing we do is tell the game to delete any potential level-specific GameObject hierarchies that may be loaded:
if (GameObject.Find("_level1")
Destroy (GameObject.Find ("_level1"));
if (GameObject.Find("_level2")
Destroy (GameObject.Find ("_level2"));
if (GameObject.Find("_level3")
Destroy (GameObject.Find ("_level3"));Inside the switch statement that ChangeState() implements, we signal a LoadLevelAdditive() call when changing to LEVEL1, LEVEL2, or LEVEL3. However, when switching to MAIN, we simply need to destroy the _level1, _level2, and _level3 GameObjects since _global remains persistent throughout.
Recall that each level-specific scene file must be constructed according...
Change the font size
Change margin width
Change background colour