Asset Bundle #1- App Dev Series 19
Quick guide: how to create an asset bundle of gameobjects.
When assets from game is too big to download it as fast as possible, Unity provides a good way to package your asset separate that allows you to downloaded it after open your app or game.
In this quick guide, I would demonstrate how to package the 3D model prefab as asset bundle.
Tag it as asset bundle
First, we need to locate the file we want to pack. In this example, I would package the only 3D model in my AR project: the horse.
When select the object in Project window, it should reveal the quick view of object in Inspector like snapshot above.
There should be a label at the bottom of it: AssetBundle.
Select the dropdown menu and select new to give it a name.
Once you name it, we can keep it here for now. We need to know how to package it as an asset bundle first.
Pack it as asset bundle
Search “AssetBundle Workflow” and you should get the Unity Documentation site.
You can read the whole page as you wish but what we are going to use to our project, is a short part of code example to pack the asset as asset bundle.
Create a new script with this code example, and notice that this script should be in the folder called “Editor” under Assets main folder.
There is one more part that you should notice that, if you are creating a mobile app with this function, you need to change the last line of code: “
StandaloneWindows” to “
Android”. Otherwise it would cause some error.
Once done, you are ready to pack the object.
Right click on the root Assets folder of your object and select Build AssetBundles.
Since the horse is the only object that select to become assetbundles, there will be a new folder was created in Assets folder called “AssetsBundles” and only one package called “horse” in it.
That is how to create an assetbundle in Unity.