How to.. "Add a delegate to this to get notifications"..

HI All,
Am using the 5.4 beta. (Just got b11).
In the SceneManagenment, there are few events

  • activeSceneChanged
  • sceneLoaded
  • sceneUnloaded

Their descriptions says like…
“Add a delegate to this to get notifications when the active scene has changed”

Have no ideas how i can do that. Can someone kindly provide an example?

For loading, since I use Load Async, I could do it in a coroutine like
yield return SceneManager.LoadSceneAsync(…)
But the other two… How do i get a notification, or wait in a coroutine?


I don’t have 5.4 beta and it’s documentation isn’t online, so i have no idea how the signature of those events look like. SceneManagenment is a namespace and a namespace can’t contain events. Is it possible that those events are inside the SceneManager class?

If those events don’t have any parameters you can simply do:

void Awake()
    SceneManager.activeSceneChanged += MyMethod; // subscribe
void OnDestroy()
    SceneManager.activeSceneChanged -= MyMethod; // unsubscribe

void MyMethod()
    Debug.Log("active scene changed");

However if the event takes a parameter (a Scene object for example) you have to declare a method that matches the signature of the event type.

Again, this is based purely on speculations since i don’t have the beta version.

using UnityEngine.SceneManagement;

void OnEnable() {
    SceneManager.sceneLoaded += OnSceneLoaded;

void OnDisable() {
    SceneManager.sceneLoaded -= OnSceneLoaded;

private void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
//do stuff

this is just a useless reacharound injected for no other purpose than to break code and caries no benefit