Streaming new assets/scenes: an overview

I’m currently working on a project which requires a central level that acts as a portal to other levels. The most sane setup would be to build a central scene, and download another scene only when needed. So I started doing some research on how to load a downloaded scene and found out the unity site isn’t as clear as I would want it to be.
It’s still not 100% clear what can be packed into an Assetbundle (new scripts? complete scenes?).

So I made a summary on all options of downloading new assets or scenes…
Can anyone check the following summary? Are these assumptions right or did I misinterpret something?

ASSET BUNDLES
Asset bundles can contain a collection of assets. Assets are meshes, animations, textures, sound, or even complete prefabs (scripts are not considered to be an asset).
Look at Unity - Scripting API: BuildPipeline.BuildAssetBundle for a description of asset bundles.

They can’t be build within the standard unity menu’s. By using Editor scripts, the unity program can be extended to offer this functionality. The function for building such asset bundles can be found at Unity - Scripting API: BuildPipeline.BuildAssetBundle.

The assetbundle can be downloaded (with the WWW class) and instantiated with following code: Unity - Scripting API: WWW.assetBundle.

! BuildPipeline.BuildAssetBundle is a pro-only feature !
Functional in targets: web, standalone, others

STREAMED SCENES
An asset bundles can’t contain new scenes (or levels). Additional scenes however can be build with an Editor script.
How to build a scene can be found at Unity - Scripting API: BuildPipeline.BuildPlayer. The BuildPlayer function can build a scene into a playable unity3d file. With the BuildOptions set to BuildAdditionalStreamedScenes (Unity - Scripting API: BuildOptions.BuildAdditionalStreamedScenes) this unity3d file can be downloaded as an assetbundle from which the new scene can be loaded.
For loading a scene from an asset bundle, thus asset bundle doesn’t have to be initiated. After downloading the unity3d file, set it to a AssetBundle variable, and just load the scene with Application.LoadLevel or LoadLevelAdditive.

! BuildPipeline.BuildPlayer is a pro-only feature !
Functional in targets: web, standalone, others

STREAMED WEBPLAYER FILES
When a scene is built to a web player version, the resulting unity3d file can also be downloaded through the WWW class. Just call the LoadUnityWeb function of WWW after downloading the file.

This option fully replaces the current webplayer instance (like going to another url with the new unity3d file), so assets, variables, states etc won’t be transferred to the new webplayer instance.

This is the only solution for loading new scenes in the free version of unity.
Functional in targets: web

Good explanation.
The Streamed Webplayer one though is missing an important fact.

You say it replaces the current scene.
This is indeed not true. Technically it actually replaces the whole webplayer instance, so you can’t carry over values nor states at all without using JS and a datacontainer outside there.

Also its available in the webplayer only, where as the other two solutions work for web and standalone (and mobiles)

As for your half question: Asset Bundles can contain only what the name implies, assets.

that means textures, meshes, sounds, text assets.
code can not be transfered through asset bundles, as code assemblies must be present at compile time in the client or they won’t be present at all.
indirectly its possible to use code from external assemblies but you can no longer use nice coding, cause you need to use reflection.
AngryAnt has a blog entry on the matter if I remember right, which shows you how you could do it theoretically.

Thanks for your reply.
You are indeed correct, LoadUnityWeb replaced the whole unity3d file, so nothing of the previous one will remain.

One more question:
Can an asset bundle also contain materials? As new materials can also imply new shaders, thus new code, so I guess not.

I edited my summary, and for people who are interested, here is the blog entry dreamora was talking about.

Anyone who knows if asset bundles can contain new materials/shaders?

Yes AssetBundles can contain materials and shaders.
Shaders are not “code” as such, with code scripts are meant that add functionality and require to be compiled in the editor.

For shader there is no such requirement nor do they even have the possibility to do such a thing, they are just instructions for the graphics pipeline

I’m still a little fuzzy. I have 15 scenes. I want the ability to load the first scene (the login scene), and once they login, I want it to (insert what needs to be done) where it would retain all the information from the previous scene (which is the login scene). I was able to use the

BuildPipeline.BuildPlayer(levels, “StreamedWebplayer.unity3d”, BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes);

But the scene file was only 1mb and normally when I just choose to build only that specific scene, it was like 13mb. It seems I am missing a step. I don’t want to have to point to all the object to add to a list, like what I am reading in Unity - Scripting API: BuildPipeline.BuildAssetBundle because the answer is ALL objects in the scene.

Thanks!