I use BuildStreamedSceneAssetBundle() to output a *.unity3d file. Then in the project view, I delete all those files I think already exists in the bundle.

In my level loading code, I use WWW.LoadFromCacheOrDownload() to load the bundle. Then try to use Application.LoadLevel() to load the level in bundle. But unity output the error “xxxx (-1) has not been added to the build settings”.

I know one should add level in Build Setting if the level is going to build into the main package. But in my case, this level is from the bundle, not the main package!

After I read manual link text for many times and try everything I can, it doesn’t work. So, please help.

My bundle building code:

@MenuItem("Builds/Build Streamed Asset Bundle From Selection")
Static function ExportResource ()
{
    var path = EditorUtility.SaveFilePanel ("Build Bundle", "", "NewResources", "unity3d");
    if (path.Length != 0)
    {
        var levels : String[] = ["Assets/Level/GameLevel/testlevel.unity"];
        BuildPipeline.BuildStreamedSceneAssetBundle (levels, "testlevel.unity3d", BuildTarget.Android);
    }    
}

My level loading code:

public bool LoadLevelFromBundle()
{
    WWW download = WWW.LoadFromCacheOrDownload("file://" + Application.dataPath + "/../testlevel.unity3d", 5);

    // Handle error
    if (download.error != null)
    {
        Debug.LogError(download.error);
        return false;
    }

    AssetBundle bundle = download.assetBundle;

    // Load the level we have just downloaded
    Application.LoadLevel("testlevel");

    return true;
}

Latest news, change second parameter of this line

WWW download = WWW.LoadFromCacheOrDownload("file://" + Application.dataPath + "/../testlevel.unity3d", 5);

to 1 make sense. But I’m still try proving it.

That’s it!

Anyone met same issue can try this method. It solves my problem. I test it in Editor (PC) and Android, both work very well.