I have made asset bundle of a scene like this
[MenuItem("MFKJ/BuildSceneAsset")]
static void myBuild() {
string[] levels = { "Assets/Scene/Scene2.unity" };
string v = BuildPipeline.BuildStreamedSceneAssetBundle(levels, "Assets/AssetBundles/Streamed-Level2.unity3d", BuildTarget.StandaloneWindows);
Debug.Log(v);
//"Streamed-Level1.unity3d"
//BuildPipeline.BuildStreamedSceneAssetBundle(levels, "Streamed-Level1.unity3d", BuildTarget.StandaloneWindows64);
}
This has made a .unity3d assetbundle file in specified folder. Now on run time i am loading the scene from asset bundle form another scene using this code.
public string url;
// Use this for initialization
void Start () {
url = "file://" + Application.dataPath + "/AssetBundles/Streamed-Level2.unity3d";
Debug.Log("scene load url : " + url);
StartCoroutine(LoadSceneBundle());
}
// Update is called once per frame
void Update () {
}
public IEnumerator LoadSceneBundle() {
using (WWW www = WWW.LoadFromCacheOrDownload(url,1)){
yield return www;
if (www.error != null) {
throw new Exception("WWW donwload had an error : " + url + " " + www.error);
//Debug.Log("");
}
AssetBundle ab = www.assetBundle;
Debug.Log(www.assetBundle.mainAsset);
//GameObject gm = ab.mainAsset as GameObject;
//Debug.Log("Scene2PassValue : " + gm.name);
//Instantiate(gm);
//ab.LoadAll(typeof(GameObject));
ab.LoadAll();
ab.Unload(false);
}
}
but unfortunately this is not loading the streamed scene or any asset of streamed scene from asset bundle. what i am missing?