Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Need help with main menu error fast

Discussion in 'Editor & General Support' started by unity_18C29E37BD626C0361FD, Apr 13, 2021.

  1. unity_18C29E37BD626C0361FD

    unity_18C29E37BD626C0361FD

    Joined:
    Apr 11, 2021
    Posts:
    3
    This error message keeps coming up when I click the play button on my main menu.

    Scene 'SceneManager.GetActiveScene().buildIndex + 1' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
    To add a scene to the build settings use the menu File->Build Settings...
    UnityEngine.SceneManagement.SceneManager:LoadScene (string)
    MainMenuPlayGame () (at Assets/MainMenu.cs:10)
    UnityEngine.EventSystems.EventSystem:Update ()

    I have added the main menu scene and game scene to the build settings and it keeps coming.

    I can post code too if needed.

    This is my first project so please bear with me.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    It kinda seems like you did something like:
    Code (CSharp):
    1. SceneManager.Load("SceneManager.GetActiveScene().buildIndex + 1");
    Instead of the correct:
    Code (CSharp):
    1. SceneManager.Load(SceneManager.GetActiveScene().buildIndex + 1);
    Is that right?
     
  3. unity_18C29E37BD626C0361FD

    unity_18C29E37BD626C0361FD

    Joined:
    Apr 11, 2021
    Posts:
    3
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class MainMenu : MonoBehaviour
    7. {
    8.     public void PlayGame ()
    9.     {
    10.         SceneManager.LoadScene("SceneManager.GetActiveScene().buildIndex + 1");
    11.  
    12.     }
    13.  
    14.     public void QuitGame ()
    15.     {
    16.         Debug.Log("QUIT");
    17.         Application.Quit();
    18.     }
    19. }
    20.  
     
  4. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    1,042
    So... did you try fixing it how PraetorBlue suggested?
     
    Kurt-Dekker and PraetorBlue like this.