- Home /
Include an AssetBundle inside other AssetBundle
Is it possible to include an AssetBundle inside other AssetBundle.
Example: I have an assetbundle with some prefabs and so. I have another Scene AssetBundle. Is it possible to create one assetbundle including the other ?
If yes, how to load them both?
Thanks in advance.
Answer by appearance · Jul 09, 2014 at 11:30 AM
I think the question was not asked in understandable manner and that's y there is no reply till this time.
Let me answer my own question, In case somebody looking for this type of info.
Assetbundle can be put into another assetbundle. This was explained in Unity Manual in "Protecting Content" in it's third approach.
Simply put, Create first assetbundle and rename it's file extension to .bytes or .txt and add it to Unity Project as TextAsset. Now you can build second assetbundle and include this renamed assetbundle as TextAsset.
How to load it: Simple. You can load assetbundle and load TextAsset which is actually inner assetbundle which was stored as TextAsset. Now, read bytes from textasset and create assetbundle from memory.
Ex:
WWW www = new WWW(url);
//or
//WWW www = WWW www = new WWW.LoadFromCacheOrDownload(url,1);
TextAsset textAsset = www.assetBundle.Load("inner_asset_bundle", typeof(TextAsset));
// Get the byte data
byte[] ab_bytes = textAsset.bytes;
// Create an AssetBundle from the bytes array
AssetBundleCreateRequest acr = AssetBundle.CreateFromMemory(ab_bytes);
yield return acr;
AssetBundle bundle = acr.assetBundle;
Hope it's clear and understandable.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to import the object from server to unity 2 Answers
Load AssetBundles on Android device 1 Answer
Unity asset store tools error asset bundles 1 Answer
Why is there no such thing as a LoadAllAsync method? 1 Answer