- Home /
Additive loading with asset bundles
Hi, I'm new to Unity and Javascript so please bear with me.
What I'm trying to do is set up a level where its contents are loaded and unloaded as the player walks through by using asset bundles. So as the player continues to walk through the level, the areas at the start will be unloaded and newer areas loaded in. I'm currently using triggers to signal asset bundle downloads and think that I will have to use Application.LoadLevelAdditiveAsync somehow. I'm not sure exactly how I will do this. Can someone please give me suggestions on how to stream a level using asset bundles. I'm developing for the iPhone.
Do you have Unity Pro? Async operations are a Pro only feature.
Answer by shaystibelman · Jan 26, 2012 at 02:50 PM
I'm doing exactly the same thing on my current project and I have found extremely useful the BuildPipeline.BuildAssetBundle like kevork mentioned. The only thing that I have just noted is that if you want to maintain lightmaps, you will have to save the entire scene and not just a prefab. To save the scene as a *.unity3d file I have used BuildPipeline.BuildPlayer and then use the buildOptions.buildAdditionalStreamedScenes in order to AsyncLoad them. That's my technique. If anybody's got a better way, do share!
Answer by kevork · Jan 11, 2012 at 10:49 PM
Personally, I'd recommend using C# over JavaScript, and not because the example on BuildPipeline.BuildAssetBundle is in C#.
If you create a script file with the code from the above link into your project in a /Editor folder, select a level you want to stream in your Project View, and go to Assets -> Build AssetBundle From Selection - Track dependencies, save the file on your disk, copy that file onto your remote computer. You now have a level that you can retrieve and stream.
You can load that level with WWW-assetBundle.
Good luck!
Downloading the level from a server isn't too hard. I'm just unsure as to how to load it the way I want. Would I still use Application.LoadLevelAdditiveAsync?
Your answer
