OnSceneWasLoaded deprecated - cannot find work around

I am following a course that is using Unity 4.6 and they are using the OnSceneWasLoaded event to do stuff.

I’ve seen the docs here which is saying to now use a delegate :-

However, this is complaining that :-

Cannot implicitly convert type `UnityEngine.SceneManagement.Scene' to `UnityEngine.Events.UnityAction<UnityEngine.SceneManagement.Scene,UnityEngine.SceneManagement.LoadSceneMode>'

The info I’ve managed to find so far suggests this should work, but struggling to find anything a solution.

using UnityEngine.SceneManagement;

Start(){
    
    SceneManager.sceneLoaded += myDelegateEvent();
    
    }
    
    void myDelegateEvent(){
    
    //DoStuff
    
    }

Am I missing some sort declaration for the delegate?

The two problems you have is sceneLoaded is a delegate with two parameters, where you provide none with your myDelegateEvent() method. you need to extend your myDelegateEvent to match the parameters like:

void myDelegate(Scene scene, LoadSceneMode mode){

}

The second mistake is the braces. Adding to a delegate, you only use the method name.

SceneManager.sceneLoaded += myDelegateEvent;

I agree, the docs could be more complete :slight_smile:
You can also let MonoDevelop help you in these cases. After you’ve finished typing the += autocompletion should show you some options, with the first one usually the parameter-list need.

Thanks so much, great answer. Really appreciate your help.