A sweet example of using assetbundles in unity
Purpose: Using Command line construct different Assetbundles after copying different assets into project folder
- Create An folder to store assetbundles, named what ever you like
- Open Unity Project "Instantiate Assetbundles", Click "Main Camera", you'll find a component called "test(Script)" in Inspector,
change the paramter to the path of the folder you just create. However leave
/testbundle
at bottom. - Open "buildAssetbundle.bat" and modified parameters above
SET UNITYPATH= Where you installed Unity SET CREATEPROJECTPATH= Path of project "Create Asset bundles" SET BUILDPATH= Path of builds of project "Create Asset bundles" SET UNITYUSER= you Unity Account
- Done
- Click "buildAssetbundle.bat", wait for console disappear (it may last for seconds)
- open the build path, you shall see a folder "StreamingAssets", copy the file "testbundle" and "testbundle.manifest" into the folder you created in Step 1 in "Before you clone..."
(Or you may change the parameter in Step2 in "Before you clone..." toyour_build_path/StreamingAssets/testbundle
, though I don't recommend it) - Build Unity Project "Instantiate Assetbundles" (this step only need to be done once), Open executable build, you will see a big white covered model in the scene.
- (Optional) Usage :
4-1. copy you model intopath_of_"Create Asset bundles"/Assets/Pinocchio.fbx
4-2. click "buildAssetbundle.bat", copypath_of_build_of_"Create Asset bundles"/StreamingAssets/testbundle
toparameters you've set in Step2 in "Before you clone..."
4-3. open "Instantiate Assetbundles" executables, you will see another model
Well, it it no big deal but using unity command line parameter : -executeMethod
, this parameter allows you executing Editor class
function when compiling.
Mr. 秉宜