Parpil
Parpil

Reputation: 129

SceneManager LoadScene is not working

I have simple button and on click i run function from my script. It goes well with main scene and mainScript and it directs it to Job scene, but then i created another jobScript that i use for job scene, i use the same function and it is not working.

Here is function:

using UnityEngine.SceneManagement;

public void changeScene(string nextScene)
{
    SceneManager.LoadScene(nextScene);
}

I really do not know why it is no working. I checked if i entered scene name correctly, and i did. If need more material, please tell me and i will update post.

Upvotes: 0

Views: 8024

Answers (3)

Komal Gupta
Komal Gupta

Reputation: 165

  1. Make sure to give exact name of scene in inspector at OnClick() event.
  2. In the script pass the right argument variable name i.e ChangeScene(string sceneName), sceneName is the right argument to pass in and as SceneManager.LoadScene(sceneName);

Upvotes: 1

Jarno Looij
Jarno Looij

Reputation: 51

You could check if you added the scene to the build

Upvotes: 1

Parpil
Parpil

Reputation: 129

Solved. I set onClick to off so i changed to RuntimeOnly and it works. Thanks. I was looking for it half a day.

Upvotes: 1

Related Questions