- Home /
Loading Asset bundles and Scenes separately
Hi All,
I'm currently making an application that can be extended depending on what the client wants. For example, one client could pay for sections 1 and 3 and another client could pay for sections 1 and 2.
I've created it in a way that we can send asset bundles that open up the sections of the app.
When the user runs the application it checks the a 'Bundles' folder and then creates GUI elements, using the subfolder names for the titles. Then when the user clicks the GUI element, the application loads all Asset bundles inside that subfolder, then loads a scene file using the name of the subfolder.
I have split the assets into multiple asset bundles because there are going to be frequent updates and I'd like the ability to send small files specific to the area I wish to update.
I originally bundled the scene file in with all dependent assets using BuildPipeline.BuildAssetBundle
This worked great, the scene loaded up and all of the assets were loaded and appearing correctly, but this meant that I couldn't split the asset bundle into the sections i wanted so that I could easily update small sections of the app.
To attempt to fix this, I built multiple asset bundles of the required assets and copied these and the original scene file to my parent app.
The problem I'm having is loading all of the elements required for the scene from the asset bundles. When the scene loads, the assets are missing (red text in the editor heirachy)
Any help would be HUGELY appreciated.
Here is the code I'm using to load the bundles and the scene:
IEnumerator DownloadAndCache (){
//Load each asset bundle in the folder
foreach (FileInfo file in fileInfo) {
string filepath = "file://" + Application.dataPath + "/../" + "/Bundles/" + project + "/" + file.Name;
www = new WWW(filepath);
yield return www;
// Handle error
if (www.error != null)
{
Debug.LogError(www.error);
return true;
}
else
Debug.Log("Loaded " +file.Name);
//I think this is where the problem is, loading the GameObjects
AssetBundle bundle = www.assetBundle;
Object[] bundleObj = bundle.LoadAll();
//This was a last ditch effort to keep all objects in the project!
foreach(Object obj in bundleObj)
DontDestroyOnLoad(obj);
}
Application.LoadLevel (project);
}
I'm still looking for any help with this. I have had some success with the BuildPipeline.BuildAssetBundle but I don't want to have multiple copies of objects within asset bundles if they are used in multiple scenes.