# Using Events

#### 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.

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O0L3LPxjA-BpuW%2Ft3_1.png?alt=media\&token=f780573f-63b7-40ad-af15-c6a6d6157e02)

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

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O2I_o3RD4FrAPt%2Ft3_2.png?alt=media\&token=bf811751-243e-4bee-a3c0-e40d978a4ce4)

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

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O3UFliXnYiLMPd%2Ft3_3.png?alt=media\&token=3a77b3a2-1cc0-418b-b885-261b18db04be)

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

```csharp
    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.

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O4Gwi0NQH3FIQ_%2Ft3_4.png?alt=media\&token=0c460daf-1896-44a7-82af-9e4cc97c91dd)

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

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O5DS1PSwdzlAty%2Ft3_5.png?alt=media\&token=a3cc4e6d-f066-4dc0-94bf-8194c6c9909b)

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

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O61jHsVX6vcOKo%2Ft3_6.png?alt=media\&token=c6823bc8-5f1f-4346-970b-c058c36929df)

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

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O7PGBRO5KK1exy%2Ft3_7.png?alt=media\&token=f8c7b4b2-5ea1-4c91-929e-9a9ca97648ca)

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

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O82WgYZkXsx05Q%2Ft3_8.png?alt=media\&token=aedd3b6e-d0fa-4274-9d1c-676f40ac7fcd)

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

![](https://2173864829-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX7wZveSDgKTUIzUGok%2F-LXTRY56Ej1o_3EXBTaH%2F-LXTR_O95vkLcb8MGBfN%2Ft3_9.png?alt=media\&token=ad2ef189-2018-4085-84bf-37ae5fcd2cce)
