Unity Asset Bundles
Objective: Package a horse prefab into an Asset Bundle within Unity.
Asset bundles are archives of non coding files such as textures, animations, models or even whole scenes, which can be loaded at run time. This allows the asset bundle to be saved in the cloud to reduce storage space for the application on a mobile device. The HorsePrefab is a good candidate as it contains several 3D models and animation, as shown below.
The initial step is to select the HorsePrefab in the project window. In the inspector at the bottom, there is an Asset Bundle menu. If the menu is not visible double click next to the HorsePrefab name below the Add Component to expand to see the preview image. Select the left hand menu and add new asset bundle, called horse. Make sure the HorsePrefab’s asset bundle is assigned to horse. The right menu for the asset bundle is used to assign variants, beyond the scope of this article, so select none.
Within the project window add a new folder called Editor to the Assets folder. Create a new C# script, CreateAssetBundles, within the Editor folder. This script adds a new option, BuildAssetBundles, to the Unity Asset drop down menu.
Save the scene and select BuildAssetBundles, which will create a new folder, AssetsBundles, and some new files, shown below.
The horse asset bundle has now been created and can be stored on the cloud to provide any user access as needed without bloating the app size.