I am performing the following to export my scene into an asset bundle:
[MenuItem("Assets/Build Web player Streamed")]
static void ExportScene(){
string level = "Assets/scenes/scene_exercise_2547.unity";
string[] levels = new string[1];
levels[0] = level;
string path = EditorUtility.SaveFilePanel (
"Save Resource",
"",
"New Resource",
"unity3d");
if (path.Length != 0) {
BuildPipeline.BuildStreamedSceneAssetBundle(
levels,
path,
BuildTarget.WebPlayer);
}
}
Then I am trying to load the asset bundle like this in Start():
IEnumerator Start() {
using (WWW www = new WWW("http://localhost:12960/animations/2547.jpg")) {
yield return www;
if (www.error != null)
debugger.text = www.error;
AssetBundle bundle = www.assetBundle;
Debug.Log ("loading level");
Application.LoadLevel ("scene_exercise_2547");
Debug.Log("level loaded");
bundle.Unload(false);
}
}
I get no errors and the two Debug.Log messages show up just fine. The problem is that whatever objects I have in the scene that is LOADING the asset bundle all disappear and no level is loaded from my asset bundle. So I don’t know if the asset bundle is empty, or if my method to load the level is not working.
Any help here would be awesome.
Thank you