AssetBundles FAQ

#How do I cache AssetBundles? #Are AssetBundles cross-platform? #How are assets in AssetBundles identified #Can I reuse my AssetBundles in another game? #Will an Asset Bundle built now be usable with future versions of Unity? #How can I list the objects in an AssetBudle?

#howdoIcacheHow do I cache AssetBundles?

You can use WWW.LoadFromCacheOrDownload which automatically takes care of saving your AssetBundles to disk. Be aware that on the Webplayer you are limited to 50MB in total (shared between all webplayers). You can buy a separate caching license for your game if you require more space.

#%item value=2%crossplatformAre AssetBundles cross-platform?

AssetBundles are compatible between some platforms. Use the following table as a guideline.

_Platform compatibility for AssetBundles_
Standalone Webplayer iOS Android
Editor Y Y Y Y
Standalone Y Y
Webplayer Y Y
Android Y

For example, a bundle created while the Webplayer build target was active would be compatible with the editor and with standalone builds. However, it would not be compatible with apps built for the iOS or Android platforms.

#%item value=3%howidentifiedHow are assets in AssetBundles identified?

When you build AssetBundles the assets are identified internally by their filename without the extension. For example a Texture located in your Project folder at "Assets/Textures/myTexture.jpg" is identified and loaded using "myTexture" if you use the default method. You can have more control over this by supplying your own array of ids (strings) for each object when Building your AssetBundle with BuildPipeline.BuildAssetBundleExplicitAssetNames.

#%item value=4%reusebundlesCan I reuse my AssetBundles in another game?

AssetBundles allow you to share content between different games. The requirement is that any Assets which are referenced by GameObjects in your AssetBundle must either be included in the AssetBundle or exist in the application (loaded in the current scene). To make sure the referenced Assets are included in the AssetBundle when they are built you can pass the BuildAssetBundleOptions.CollectDependencies option.

#%item value=5%futureplayerWill an Asset Bundle built now be usable with future versions of Unity?

Asset bundles can contain a structure called a type tree which allows information about asset types to be understood correctly between different versions of Unity. On desktop platforms, the type tree is included by default but can be disabled by passing the BuildAssetBundleOptions.DisableWriteTypeTree to the BuildAssetBundle function. Webplayers intrinsically rely on the type tree and so it is always included (ie, the DisableWriteTypeTree option has no effect). Type trees are never included for mobile and console asset bundles and so you will need to rebuild these bundles for each new version of Unity.

#%item value=6%futureplayerHow can I list the objects in an AssetBudle?

You can use AssetBundle.LoadAll to retrieve an array containing all objects from the AssetBundle. It is not possible to get a list of the identifiers directly. A common workaround is to keep a separate TextAsset to hold the names of the assets in the AssetBundle.

back to AssetBundles Intro