"assetbundle Create and load "
Unity has two dynamic loading mechanisms: one is resource.load. One is Assetbundle. Assetbundle is a feature provided by Unity Pro that encapsulates multiple game objects or resource binaries into assetbundle. For loading, decompression and use.
" Create Assetbundle"
How to use Buildpipeline.buildassetbundle (Object, assets, pathName, options, TargetPlatform)
Parameter 1: It can only put one object.
Parameter 2: You can put an array object.
Parameter 3: Save the path.
Parameter 4:builderassetbundleoptions
Collectdependencies//contains all dependencies.
completeassets//force contains the entire resource
disablewritetypetree//does not contain type information in the resource bundle.
The deterministicassetbundle//compiled resource bundle uses a hash table to store the object ID in the resource bundle.
uncompressedassetbundle//does not compress assetbundle, it is compressed by default
Parameter 5: Platform
Special note is that the computer and mobile phone on the assetbundle can not be mixed, different platforms can only use their own.
" load Assetbundle"
How to use:
1) www bundle = new www (path);
2) WWW bundle = WWW.LoadFromCacheOrDownload (path, filever);
After a successful load, you can use the Bundle.assetBundle.Load method to get the resource using the resource name.
As shown
Using Assetbundle.load reads and creates a asset object from the Assetbundle memory image , creating the same memory that is allocated for deserializing the storage.
" Memory Free "
Finally, the best way to use Assetbundle is.
When created: loads the required asset with Assetbundle.load, Assetbundle.unload (false) immediately after loading, releasing the memory image of the Assetbundle file itself, but not destroying the loaded asset object. You can release a portion of the memory in this way.
When released. If the object is instantiate, destroy it with destroy. Use Resources.unloadunusedassets in the right place to release asset that have not been referenced. The bottom of unity will count the object reference, if the reference is 0. Execution of Unloadunusedassets can be completely released.
" key points of use "
1, Assetbundle will use LZMA compression.
2, the resources under resource will become Resources.assets file, 2G disk size limit. Full download for the first time, not updatable.
3, Assetbundle Local Disk cache can be up to 4G, in addition to the Web version only 50M.
4, compatibility.
5, Assetbundle Creation method:
6, the difference between bundleoption.
7, Assetbundle.createfrommemory () speed slow.
8, Assetbundle.createfromfile can only load non-compressed assetbundle.
9, Loadlevel method Detailed:
10, the release of Assetbundle.
Assetbundle Creating and loading