Using Events

Last updated 2 months ago

What to learn?

  • Connect events from Scene Flow Manager

Steps

  1. Setup a working game flow follows the previous tutorials. We have a simple flow setup here.

  1. 2. Open the bootstrap scene. Select the Scene Flow Manager.

3. Add a new script and name it DemoEvents.cs ( You can use your own name or script).

4. Open the DemoEvents.cs and add functions called HandleLoadEvent() and HandleUnloadEvent().

public void HandleLoadEvent(SceneInfo current, SceneInfo next)
{
Debug.Log("[HandleLoadEvent] Current: " + current.SceneName + " Next: " + next.SceneName);
}
public void HandleUnloadEvent(SceneInfo current, SceneInfo next)
{
Debug.Log("[HandleUnloadEvent] Current: " + current.SceneName + " Next: " + next.SceneName);
}

5. From the inspector, open the events foldout and you will see a list of events.

6. Press the "+" button and add a new event under OnSceneLoaded event.

7. Drag and drop the Scene Flow Manager gameobject to the object field.

8. From the functions drop down, select the HandleLoadEvent() from the DemoEvents object.

9. Repeat the steps for OnSceneUnload event and HandleUnloadEvent() function.

10. Play the scene. You will see the events log in the console when you run the project.