So I’ve been trying to figure out how to switch from one scene to another within Unity 5.3, but I’m having trouble when I call upon the function that is supposed to load the next scene. The scene doesn’t change and an error pops up saying that:
Scene ‘Scenes/Main Scene.unity’ (-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
I’ve tried changing the name for the scene in the inspector and I’ve added the scene into the build settings, and I still am having trouble. To be completely honest, though, I don’t know what the problem is. I’ve never dealt with scenes (normally, I just make one scene). So, I’ll just provide as much information I can and hope that the Unity Community can help me understand why the scene isn’t changing and the above error is appearing.
Here’s my script for changing scenes:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class MenuScript : MonoBehaviour {
public Canvas quitMenu;
public Button startText;
public Button exitText;
[SerializeField]
string m_MainLevel = string.Empty;
void Start () {
quitMenu = quitMenu.GetComponent<Canvas> ();
startText = startText.GetComponent<Button> ();
exitText = exitText.GetComponent<Button> ();
quitMenu.enabled = false;
}
public void ExitPress()
{
quitMenu.enabled = true;
startText.enabled = false;
exitText.enabled = false;
}
public void NoPress()
{
quitMenu.enabled = false;
startText.enabled = true;
exitText.enabled = true;
}
public void StartLevel(){
SceneManager.LoadScene (m_MainLevel);
}
public void ExitGame()
{
Application.Quit ();
}
}
The scene that I’m trying to get to is named Main Scene.
Within the inspector, I have defined Main Level as Scenes/Main Scene.unity, which is what I copied from the build settings when I added the scene to the settings.
I have not messed around with AssetBundles and I have no idea what they are.
If you need any additional information, please let me know!