Nuds
Nuds

Reputation: 64

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);
    }
}

Upvotes: 1

Views: 1755

Answers (1)

Programmer
Programmer

Reputation: 125315

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.

Upvotes: 6

Related Questions