- Home /
Help with loading scenes.
I want it to load only one scene but it loads 2 of the same scene "Game Option". I don't know the problem. When I press escape, I have to click on resume twice because of it.
My Code
public static bool GameisPaused = false;
public GameObject pauseMenuUI;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameisPaused)
{
Resume();
}
else
{
Pause();
}
}
}
public void Resume()
{
GameisPaused = false;
SceneManager.UnloadSceneAsync("Game Option");
Time.timeScale = 1f;
}
void Pause()
{
GameisPaused = true;
Time.timeScale = 0f;
SceneManager.LoadScene("Game Option", LoadSceneMode.Additive);
}
Answer by danelforty · Dec 01, 2019 at 12:52 AM
What do you want to do? Are you trying to load a scene when you click "escape" and when you click it again, go back to the first scene?
for some reason when I click escape key, it duplicates the "Option $$anonymous$$enu" twice ins$$anonymous$$d of once. And because of that, I have to press resume in my Option $$anonymous$$enu twice to go back to the game. I want to duplicate it only once.
Answer by Ermiq · Dec 01, 2019 at 12:22 PM
Do you have "Game Option" scene loaded on the game start? Because it looks like you have two instances of the "Game Option" scene when you pause the game.
If your game starts with "Game Option" scene, then you need to unload it when you load the "Game" scene upon the start.
Your answer
Follow this Question
Related Questions
Scene loading delay after upgrade 4.6 to 5. 0 Answers
How Do I Link Different Scenes? 4 Answers
Asset Bundle starts loaded 0 Answers