- Home /
Build index is trying to fond scene 2 even though I think I'm telling it to find scene 1
I'm trying to create a main menu and change from scene0 to scene 1, but for some reason, it is trying to load scene 2 and I get the following error message:
Scene with build index: 2 couldn't be loaded because it has not been added to the build settings. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.SceneManagement.SceneManager:LoadScene (int) MainMenu:PlayGame () (at Assets/Scripts/MainMenu.cs:10) UnityEngine.EventSystems.EventSystem:Update ()
I have two scenes in the build editor, 0 and 1 and I don't know why it is trying to find a scene 2.
Here is my code:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class MainMenu : MonoBehaviour
 {
 public void PlayGame()
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     }
 }
 
Answer by logicandchaos · May 15, 2021 at 04:13 PM
You have to go into the build settings in the unity editor and add in the scene to the build.

Answer by WarriorGecko · May 15, 2021 at 04:55 PM
NVM fixed it, just had my menu and game on the same scene
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                
