Changes to the game level controller
The game level controller will also need to be updated now, to make the necessary changes to the GameMaster
object. We will need to update the LoadLevel()
function as follows:
public void LoadLevel() { switch (GameMaster.instance.LevelController.Level) { case 0: { SceneManager.LoadScene(SceneName.CharacterCustomization); break; } // load level 1 case 1: { GameMaster.instance.PlayerCharacterGameObject = GameObject.FindGameObjectWithTag("Player") as GameObject; SceneManager.LoadScene(SceneName.Level_1); break; } } }
This will make sure that GameMaster is updated with the proper player character data. Let's go ahead and test the code.