SceneManager.SceneLoaded method showing overload error

I double checked my code against Unity’s documentation and it matches, but I’m still getting this error: “No overload for ‘OnSceneLoaded’ matches delegate 'UnityAction<Scene, LoadSceneMode>”

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

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

void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
   if (firstPlay) return;
   //load saved data to strings
   LoadSaveGameData();
   //destroy all of the objects that are going to be loaded
   DestroyAllSaveableObjectsInScene();
   //load saved objects from strings
   CreateGameObjects();
}

Can you show the full script?

Do you have any scripts in your project named “Scene” or “LoadSceneMode”?

2 Likes

Praetor had it right for me at least - I forgot I had created an enum called “scene” in that same class.

This is the 2nd time I’ve googled for this answer. So I’m commenting that the solution was, for me, also that I had a script called “Scene”. Must change that :smile:

2 Likes