Understanding Asset Bundles and How to Create Them
Last updated
Last updated
Asset bundles are a standardised packaging system used by Unity to compress assets into a package. These packages are usually loaded in real-time, from a location outside the app (like a server somewhere else in the world). This makes it possible to create and load new objects into an app without updating the main product (in our case, the V-BLDR Project).
A simple way to understand bundles is to think of them like a zip folder. The asset bundle is the zip file, and Unity can unzip the folder and get objects or data from it in real-time.
To create asset bundles that work with the V-BLDR, there are a few steps to follow:
Make sure all file names are unique for all objects and scenes. An easy way to do this is to add a prefix linked to your organization to all prefabs, scene files, and folders used to make bundles. For example, if you're using VLGE:
An asset bundle folder could be named vlge_kitchenobjects and could include the VLGE_KitchenTable & VLGE_KitchChair prefabs.
NOTE: We strongly recommend naming all asset bundle folders in lower case letters to make sure they work well with as many external tools as possible.
Objects that you want to package need to be inside a folder. For objects, these should be Unity Prefabs. You can have multiple prefabs in a single asset bundle. To do this, just put multiple prefabs in one folder. This is a common practice and can help manage memory.
For scenes, it's best to only have one scene file per folder. While it's possible to have multiple scene files, it's not the best way to manage memory.
After you have the scenes/objects in a folder you're happy with, we need to give them an asset bundle tag.
NOTE: Unity has a UI bug with asset bundle names and Two Column Layout in the project inspector. To avoid this issue, right-click on the "Project" tab and select "One Column Layout."
Choose the folder you want to turn into an asset bundle. In the bottom right corner (in the Inspector menu, make sure you can see an Inspector Window if you can't find it), you'll see an "Asset Labels" area. In the AssetBundle tab, create a "New..." tag for the folder, and make sure the asset tag matches the folder name.
After you've finished all these steps, open the BLDR SDK Window (go to Windows/BLDR SDK Window). You'll see a button that says "Build all Bundles." Click this to automatically create the asset bundles for all folders that have an Asset Label. If you don't want to rebuild old bundles, you can remove their asset label after building.
The bundles will be created in your Asset Bundle Folder. You can find this by going to the root of your Unity Project and opening the "AssetBundles" folder.