Scene 'Assets/First level.unity' (-1) couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.

Hi guys, to day i crated 2 scenes, the first is ‘First level’ where is my robot and his adventure, and the second is 'MainMenu². where you can Start the Game, and Quit the Game. All was okey, i could start and play. But after, i crated an build settings, and after build it, i couldn’t die, my restarter script didn’t work. I checked everywhere on unity answer same problem, but i didn’t find…
So the error message is: Scene ‘Assets/First level.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…
UnityEngine.SceneManagement.SceneManager:LoadScene(String)
UnityStandardAssets._2D.Restarter:OnTriggerEnter2D(Collider2D) (at Assets/Standard Assets/2D/Scripts/Restarter.cs:13)

If you need more infos just ask me, Can you help me please? :frowning:

I may have misunderstood your question but try the following:

open build settings and drag your First Level scene into the the top section where your other scenes are. Locate the index number next to the scene name and put that number in your script.

hello, I have met the same error just now, and I solved it. I have written a wrong letter when I passed the scene name to the function “SceneManager.LoadScene(sceneName);”, so maybe you should check your parameter also. @WaRZa

Check out if the scenes are ticked 182019-a.png

Hi! If you are using SceneManager.LoadScene(Scenename); make sure you enter the name of the scene instead of entering the build number of your scene.

uhhh… I’ve checked the spellings and that dorta things but it still doesn’t work. It works when I build & run the game though, just not in the editor??

@Twinklier Make sure you don’t mix up the names of the Assetbundle and the scene. I got the same error message, because this happened to me. I dragged my scene named “02” into the Asset Bundle Manager. This gave me the default AB name of “02”. I renamed it to “level1”. Loadung the scene itself by providing “level1” did not work because of the reasons which are obvious.

Now, when I load the Assetbundle, I use “level1”. And when it is loaded, I load the scene by providing “02” in the function call.

No need to add the scene “02” to the build settings.

I followed this tutorial:

I had the same problem but none of above solutions would help - spelling was correct, I did not used index, I used scene name (string). In my case solution was just removing calling and called scene from build and adding those again… Error showed up when just updating Unity IAP plugin.

I had the same problem. Turns out all I had to do was remove my scene from the build settings and add it back in. Must be a glitch or something.,Just had the same problem. All I did was remove my scene from the build settings and then added it again. Must just be a glitch or something.

I encountered this issue (a scene load that used to work, stopped working) today after restoring in “Collab”. It seemed that Unity got confused, but after going to File–>Build Setttings -->Build, it started to work.

That this worked, implies that there is a type of caching in the background that you need to figure out how to flush out.

I hope this helps somebody.
J

For using Scene manager you need to write in the start of your code:

using UnityEngine.SceneManagement;

Then for loading scene use:

SceneManager.LoadScene("level_1");

Then go in build setting on File (in Unity) and add your scene to the list

public class levelLoading : MonoBehaviour
{
public void LevelChangeBtn()
{
SceneManager.LoadScene(“levelTwo”);
}

}