Legacy Documentation: Version 5.5
Including scripts in AssetBundles
AssetBundles FAQ

Optimizing disk seeks with AssetBundles

Unity serializes data so that it is read linearly when a game loads. This cuts down the number of seeks on slow spinning hard disk computer drives (HDDs). It is unlikely to have an effect on solid state computer drives (SSDs).

A Scene’s data (the sceneN file and sharedassetsN.assets file) is sorted by object type. This takes into account the type dependencies (such as Assets, ScriptableObjects and MonoBehaviours). During Scene load, all Scene Assets are first loaded sequentially together, then Scene-reading objects are loaded linearly. The same applies to Scene AssetBundles, which contain the same data packaged in a single file.

Assets from non-Scene AssetBundles (which essentially represent a single sharedassets.assets file) are serialized in the same way as Scene AssetBundles, but the load pattern is defined by the AssetBundle’s Asset-loading API usage. They might not all be loaded together at once after the AssetBundle load, meaning that they might be read in a random access pattern.

When loading Assets from a normal AssetBundle, Unity creates a list of all the dependencies and loads them in the order they are stored in the file.

Behavior to note

  • Some asynchronous loading functions (such as streaming audio and asynchronous Texture loading) can break the linear read pattern, even for Scenes.

  • For dependent AssetBundles, even AssetBundle.LoadAllAssets does not guarantee linear access, because there could be dependent resources from other bundles. To minimize disk seeks, all dependent AssetBundles must be loaded with the AssetBundle.LoadAllAssets API.

  • DeterministicAssetBundles do not destroy the linear read and do not change the type sorting order, but do retain the object’s position within a certain type range.

  • AssetBundles with chunk-based compression (also known as (LZ4 compression) do not destroy the linear read, but may affect the granularity of the read. For more information, see the Unity Manual Asset Bundle Compression page.

Including scripts in AssetBundles
AssetBundles FAQ