Book Image

Creating E-Learning Games with Unity

By : David Horachek
Book Image

Creating E-Learning Games with Unity

By: David Horachek

Overview of this book

Table of Contents (17 chapters)
Creating E-Learning Games with Unity
About the Author
About the Reviewers

Refactoring level 3

When level 2 signals level 3 to load (when the player pressed the level 3 pop up's Continue button), it signals for the _level2 Gameobject to be destroyed and the _level3 GameObject to be loaded from the LEVEL3 scene file. We must refactor the start up logic of _level3 so that we can find and connect some object references to GameObjects in the _global hierarchy. To accomplish this, perform the following steps:

  1. Create a new script named Level3Extras, and attach an instance of it to the _level3 GameObject. This script will be used to directly access certain GameObjects inside _level3 for enabling and disabling.

  2. Give the Level3Extras script the following single public GameObject reference. The Level3Extras script needs a reference to the setupLevel3 object so that it can connect this reference to the appropriate pop-up button later on in the script:

    public GameObject setupLevel3;
  3. Drag-and-drop the SetupLevel3 GameObject from the _level3 GameObject hierarchy into the SetupLevel3...