What is? AB packageAB Full name AssetBundle( Resource Pack ). When you get AssetBundle after , You can also call AssetBundle Corresponding API To load resources. Namely Resources How to load resources. Unity There's a special folder Resources, Resources placed in this folder can be accessed through Resources.Load() To load directly. Another way to read and write data from a text file that’s in a specific directory is to use the StreamWriter and StreamReader classes from the System.IO namespace to access characters from a byte stream and then load the file as a TextAsset in Unity.Stay Unity in , Generally speaking , Resource loading methods are mainly divided into Resources Load and AssetBundle load. In addition, certain third-party and first-party assets.
Invalid Serialized File Header Unity Code Is The( To hot update you need to make sure that AB The resources generated by the package are unique , And the same resources AB The packet inspection code is the same. Why use AB package1、 Hot update. By distributing resources in different AB The package can minimize the memory pressure at run time , And you can selectively load content.Such as UncompressedAssetBundle yes 0000 0000 0001,IgnoreTypeTreeChanges yes 0000 0100 0000,DisableLoadAssetByFileName yes 1000 0000 0000.BuildAssetBundles The bottom layer will respond to the incoming BuildAssetBundleOptions Value to process , According to the number of binary bits to determine which strategy to use to build AB package. Only one bit is 1, The others are 0. It is not recommended to use in large quantities Resources.Hit AB package : `public static AssetBundleManifest BuildAssetBundles(string outputPath, BuildAssetBundleOptions assetBundleOptions, BuildTarget targetPlatform) `BuildAssetBundleOptions The value of enumeration type is converted to binary. Resources All the resources in the folder are consolidated into one serialized file ( It can be seen as a big package , Giant AB If there is a problem with the bag, it will have a problem ), There are certain restrictions on resource optimization. It takes a long time to load when opening an application.Greatly reduced memory footprint. If AB Bag is LZ4 Loading mode , It only loads AB Bag Header, What resources are needed to load that part later AB package chunk. From a file AB package , It loads from a given path AB package. Set up resources AB Package name : `AssetImporter.assetBundleName // AB Package nameAssetImporter.assetBundleVariant // AB Package variant name `Obtain AB Package method : `AssetBundle.LoadFromFile(string path)AssetBundle.LoadFromFileAsync(string path)AssetBundle.LoadFromMemory(byte binary)AssetBundle.LoadFromMemoryAsync(byte binary)AssetBundle.LoadFromStream(Stream stream)AssetBundle.LoadFromStreamAsync(Stream stream)LoadFromFile Is to load. BuildTarget Parameters are used to select the platform to target , because AB Packages are not compatible on different platforms.![]() AB Package variantsNamely AssetBundleVariant.AB Package variants are used to support customized parameters , Allow differences AB The difference in the bag Object In loading and parsing instance ID Reference is displayed as the same Object.Conceptually , Allow two Object Show as sharing the same GUID and Local ID, But it was actually Variant ID To distinguish between. There's a lot more to it AssetBundle Methods , official API There is a detailed introduction to. Follow LoadFromFile equally , If AB Bag is LZ4 Loading mode , It also only loads AB Bag Header.(LoadFromStreamAsync It's an asynchronous version of it )assetName, Type resType)AssetBundle.LoadAssetAsync(string assetName, Type resType)`LoadAsset It's the synchronization method ,LoadAssetAsync It's an asynchronous method. (LoadFromMemoryAsync It's an asynchronous version of it )LoadFromStream It's loading from the stream AB package , It comes from a Stream Load in AB package. It will complete AB The package loads out. In memory byte Load in AB package. BuildAssetBundleOptions:None - 0: Default mode. Stay Unity In the lower right corner of the editor AB After the package name is the settings AB Package variant name. High definition and low definition resources like a picture , The first mock exam is a high precision and low precision resource. Although the inclusion body is large , But it loads fast. )UncompressedAssetBundle - 1: Uncompressed. (LZMA It needs to be fully decompressed before the resources in the package can be loaded ,LZ4 The resources in the package can be loaded without full decompression. That's why the first load takes a long time , After that, the loading time is not that long. After the first decompression , The package will use LZ4 The compression algorithm compresses again. StrictMode - 512: If there are any errors in the build , The build is not allowed to succeed. ChunkBasedCompression - 256: Use block based LZ4 Compression algorithm. AppendHashToAssetBundleName - 128: Add hash to AB Package name. IgnoreTypeTreeChanges - 64: As incremental build detection , Ignore type tree The change of. DeterministicAssetBundle - 16: Create a hash to map the data stored in AB Of the object in the bag id.ForceRebuildAssetBundle - 32: Forced reconstruction AB package. Although it can make AB The bag is smaller , But it's not compatible with lower versions. LZMA and LZ4LZMA It's stream compression (stream-based). AssetBundleStripUnityVersion: Build from compressed and serialized files header Remove Unity Version number. DisableLoadAssetByFileNameWithExtension - 8192: prohibit AB Packages load resources with file extensions. LoadFromFile() and LoadFromStream() Will only load AB Bag Header, relative LoadFromMemory() For example, it saves a lot of memory. If you need to decompress random read in real time , Block compression is a better choice. Block compressed data is divided into blocks of the same size , And compressed separately. LZ4 It's block compression (chunk-based). So load AB Packet time , You need to unzip the entire package , It can cause stuck and extra memory. AB The resources in the package need to pass through AssetBundle.Load() To load it into memory. (AB There can also be pictures in the bag 、 texture of material 、 Animation 、 Audio and other resources )And then by loading AB How to pack , take AB Load the package into memory. , With Stream Stored in memory in the form of. The downloaded resources include AB package 、 picture 、 texture of material 、 Animation 、 Audio etc. Install google authenticator for macAnd the modification of the instantiated object will affect Shader and Texture resources. In other words , When AB In bag Shader and Texture After the resource is unloaded from memory , Instantiated Shader and Texture There will be a loss of resources. About Shader and Texture Come on , Usually it doesn't need to be changed , So it's instantiated by reference. And the modification of the instantiated object will not affect the GameObject resources. In other words , When AB In bag GameObject After unloading from memory , Instantiated GameObject It won't be lost. Each resource has its own way of instantiation , Pay attention when unloading resources. AB The package must be loaded into memory from the hard disk or network first , And then AB Every resource in the package is loaded into memory , Then instantiate these resources in memory. And the modification of the instantiated object will not affect the Material and Mesh resources. In other words , When AB In bag Material and Mesh After the resource is unloaded from memory , Instantiated Material and Mesh There will be a loss of resources. ( Every class It corresponds to a ID, Such as 0 yes Object class ,1 yes GameObject Class etc. TypeTree( Optional , Yes, No TypeTree How to build ): Recorded Asset Object's class ID.Unity It can be used class ID To serialize and deserialize a class. AssetHeader: Recorded TypeTree size 、 file size 、format Etc. Of each resource name、offset、length Etc. AssetFileHeader: Contains a list of files , Records the. This is a AB The package corresponds to. AssetRef: Recorded AB Package to external resource to reference. ObjectPath: Recorded path ID( Resource unique index ID) etc.
0 Comments
Leave a Reply. |
Details
AuthorHank ArchivesCategories |