a . write in front
It is convenient to manage resources through assetbundle. There are many kinds of packaging and loading strategies for assetbundle, this article describes a way to load resources in a specified directory by using a resource name. It is intended to deepen the understanding of resource management.
two . Strategy Introduction
1. The strategy of Packaging granularity Division
① all files in the specified directory, i.e., RootList, are packaged as separate nodes.
② for all resources that RootList relies on, that is, deplist, where the number of dependencies is greater than 1, is packaged as a single node, equal to 1, and merged up to the dependent node.
③ Recording Packaging information
2. Download Policy
① Download configuration file
② Update Assetbundle file
3. The loaded Policy
① resources corresponding to the hint does not exist, report no exception, if there is a transfer down
②hint reference number increased, dependent hint reference number increased
③ if the bundle in the hint is empty, load the bundle and load the bundle that is not loaded in the dependent hint
④ if hint inside Mainasset is empty, load mainasset
⑤ return hint inside mainasset
4. Release policy
① resources corresponding to the hint does not exist, report no exception, if there is a transfer down
② all dependent hint reference number minus 1, corresponding hint reference number minus 1
③ if hint is a reference number of 0 o'clock, empty mainasset and call unload (true) to the bundle
three . Note
1.Assetbundle when loading its own asset, it is necessary to ensure that all resources have been loaded within this bundle or in other assetbundle that are loaded to ensure that the load is completely correct.
2. When you package resources, you can filter them, and filter out the non-packaged types or the specified resources.
3. Extensible: Record file MD5 change, make incremental package.
4. This method can minimize Assetbundle load resource memory consumption, but increase the number of assetbundle.
Four. Source code
Monsterabsystem
[Unity] A brief talk on Assetbundle dependencies packaging and loading