- Home /
Importing a scene from AssetBundle
Hello, i'm trying to understant the AssetBundle, by doing some exemples from the scripting references of unity. It went well for the AssetBundle that contains game objects . But when it came to import the scene in an AssetBundle that contains levels (built it using : BuildPipeline.BuildStreamedSceneAssetBundle(levels, path, BuildTarget.WebPlayer)
) I couldn't find how ! Can Anyone help me?
Im not sure what you are asking, what do you mean by "import" the scene? Can you clarify the question?
I mean load it, use it from the assetBundle. Stream it maybe?
Answer by vbbartlett · Feb 13, 2013 at 08:38 PM
Here is where it is described The only difficulty is knowing the name of the level. You would end up downloading the streamed scene and then just call load like the example.
Work flow from me is, collect all the assets in a scene and compare them to another scene and all common assets get selected and then I create an assetbundle from that set of assets.
BuildPipeline.PushAssetDependencies();
// Build asset bundle from Common assets
..
BuildPipeline.PushAssetDependencies();
BuildPipeline.BuildStreamedSceneAssetBundle(...) //Scene A
BuildPipeline.PopAssetDependencies();
BuildPipeline.PushAssetDependencies();
BuildPipeline.BuildStreamedSceneAssetBundle(...) //Scene B
BuildPipeline.PopAssetDependencies();
BuildPipeline.PopAssetDependencies();
Each scene will then be the minimum set of assets needed.
When loading you load the commonAsset bundle, then the scene asset bundle.
$$anonymous$$y problem is not the building step, it's the loading step. After the build, the upload of the asset, then the downoad o when i have to use the scene from the assetBundle, wich steps do i have to follow ?
So after getting the assetbundle from the www cache download, looks like you have to just call an Application.LoadLevel("levelname");
If that doesn't work you might try a getting the bundle and calling load() or even LoadAll in combination with the application.LoadLevel
(Part of our pipeline I am currently working on... :(
I tried that, but it doesnt work as well, the levelname you put in Application.LoadLevel("levelname");
is the name of the level in your asset folder, the one you add on the build Setting before building. So when you call Application.LoadLevel("levelname");
it doesn't load the scene on your AssetBundle, it loads the scene in your asset folder. Dont know if i made myself clear lol ! I give up using this function "`BuildPipeline.BuildStreamedSceneAssetBundle(levels, path, BuildTarget.WebPlayer`", i'll just add an empty scene to the project, and fill it at runtime ,with objects that i load from an assetBundle of objects.