Nuds Nuds - 3 months ago 68
C# Question

SceneManager.SceneLoaded signature issues

I'm not understanding what's wrong with this implementation. Perhaps someone could shed some light on the issue. The compiler is stating that there is no overloaded method for StartGame that matches the delegate. Am I missing something silly here?

void Start()
{
SceneManager.sceneLoaded += this.StartGame;
director = GetComponent<Director>();
}

public void LoadGameLevel()
{
SceneManager.LoadScene("Debug");
}

void StartGame(UnityAction<Scene, LoadSceneMode> sceneInfo)
{
foreach (GameObject player in players)
{
Instantiate(player);
}
}

Answer

This is how the event is defined: public static event UnityAction<Scene, LoadSceneMode> sceneLoaded;

Replace

StartGame(UnityAction <Scene, LoadSceneMode> sceneInfo)

with

void StartGame(Scene scene, LoadSceneMode sceneMode).

That should solve your problem.

Comments