Can I use Prefabs instead of Scenes for AssetBundles?

Hey everyone,

Just wanted to sanity-check an idea we’ve been throwing around. It came as a bit of a blow to us that you can’t include scenes in asset bundles, since we were counting on this to deliver level packs for our Android/iOS game. I’ve heard that the ability to do this will be included in Unity 3.4, but we can’t really count on that releasing before we launch.

As an alternative, we were thinking that we could create a prefab that includes all the unique elements of a scene and then include that prefab in an asset bundle with a name like “Pack2_Level3”. So, essentially, we would be creating a prefab with all the level objects as children, naming it uniquely, and then packing it into an asset bundle.

Then, on the other end, we have a basic level with common elements, and we can then call


to create unique levels without including scenes in asset bundles.

Does this seem reasonable? Has anyone used this method before? Are there any potential issues or limitations that I’m missing - ie memory on mobile devices, time required to load prefabs, prefab size? I feel that this idea is conceptually solid, but there might be some practical issue that I’m unaware of.

Not exactly an answer to your question but I am not sure you cannot do your first choice!
Have you looked at BuildPipeline.BuildPlayer, specifically with the BuildOptions.BuildAdditionalStreamedScenes option? It allows you to download extra scenes (with assets included) in an asset bundle. I think what trips everybody up is that you cannot simply include scenes into the BuildPipeline.BuildAssetBundle call instead you must use the other BuildPlayer method to include them.

As an answer to your question…

This is exactly how you would create these extra levels (if you do not opt for the more direct method stated above). We are using something similar but we are using one asset bundle for the environment, another for the vehicle, another for the vehicle skin, etc. so that we can have a number of dynamic elements.

As far as memory goes just unload the asset bundle, and all the unused assets with it, and Unity will somewhat automatically reduce your memory requirements to the bare necessity.

As for loading time, on the iPhone (3GS+) and iPad has been nominal and for most of our stuff almost unnoticeable.