Search code examples
scriptingruntime-errorunity-game-engineassetbundle

How Do I Load A Assets Bundle


So I have created this object which is supposed to load a game over screen whenever I touch a gameobject. However, when I run it, I get this run time error

Scene 'A' (-1) couldn't be loaded because it has not been added to the build settings or the asset bundle has not been loaded. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.Application:LoadLevel(String) NewBehaviourScript:OnCollisionEnter(Collision) (at Assets/NewBehaviourScript.cs:10)

Here's my code:

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour
{
    void OnCollisionEnter (Collision col)
    {
        if(col.gameObject.name =="Hurt") 
        {
            Application.LoadLevel("A");
        }
    }
} 

Solution

  • It means your scene is missing from the Build Settings.

    Go to File-> Build settings then you are given a window, you need to drag and drop all the needed scenes.

    That is not related to Asset Bundle.