In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the AssetBundle compression and decompression of what is the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this AssetBundle compression and decompression is what the article will have a harvest, let's take a look.
First, the compression mode of AssetBundle
Unity supports three compression methods for AssetBundle packaging: LZMA, LZ4, and no compression.
1. LZMA compression mode
Is a default form of compression, the standard compression format is a single LZMA stream serialized data file, and the entire package needs to be decompressed before use. LZMA compression is a popular compression format, which can minimize the compressed files, but the decompression is relatively slow, resulting in a long decompression time when loading.
2. LZ4 compression mode
Unity supports LZ4 compression, which allows a greater amount of compression and does not need to decompress the entire package before using the resource package. LZ4 compression is a "Chunk-based" algorithm, so when an object is loaded from a LZ4 package, only the corresponding module of that object is unzipped, which is faster, meaning you don't have to wait for the entire package to be unzipped. The LZ4 compression format was first introduced in the Unity5.3 version, and previous versions are not available.
3. Uncompressed way
Uncompressed packaging will be very large, resulting in a lot of space, but once the Assetbundle is downloaded, the access is very fast. This way of packaging is not recommended, because the loading function is now very friendly, you can use the loading interface to load resources in the background, and the time is not long.
Second, the cache of the compressed package
The WWW.LoadFromCacheOrDownload function downloads and caches resource packages to disk, which greatly speeds up future loads. Starting from Unity5.3, cached data can also be compressed with LZ4 algorithm, which can save 40% Murray and 60% space compared to not compressing cached data. It is compressed during the download, so it is almost invisible to the user. Data received from a socket (Socket) is decompressed by Unity and compressed in LZ4 format. This compression occurs during a streaming download, which means that once enough data is downloaded, the cache traversal begins to compress, and this continues until the download is complete. Then, when needed, the data is read out of the cache by rapid decompression.
Cache compression is enabled by default and is controlled by the Caching.compressionEnabled property, which affects resource bundles saved on disk and cached in memory.
III. Overview of AssetBundle loading API
The following table compares the memory and performance overhead when using different compression methods and different loading methods:
Do not compress LZ4 compress LZMA compress WWW load memory: size of uncompressed resource bundle (+ size of uncompressed resource bundle when WWW is not Disposed)
Performance: no additional process memory: size of LZ4 zip package (+ size of LZ4 zip packet when WWW is not Disposed)
Performance: no extra processing memory: size of the LZ4 package (+ size of the LZMA package when WWW is not Disposed)
Performance: when downloading, LZMA decompression process + LZ4 compression process LoadFromCacheOrDownload load memory: no additional memory footprint
Performance: the process of reading from disk
Memory: no additional memory footprint
Performance: process memory read from disk: no additional memory footprint
Performance: process of reading from disk LoadFromMemory (asynchronous) loading memory: uncompressed resource bundle size
Performance: no additional processing memory: size of the LZ4 highly compressed resource bundle
Performance: no additional processing memory: no additional memory footprint
Performance: the process of reading from disk LoadFromFile (asynchronous) loading memory: no additional memory footprint
Performance: process memory read from disk: no additional memory footprint
Performance: process memory read from disk: size of LZ4 package
Performance: read from disk + LZMA decompression + LZ4 compression process WebRequest (also requires cache) load memory: uncompressed resource bundle size
Performance: no extra processing [+ read from disk if cached] memory: size of LZ4 zip package
Performance: no extra processing [+ read from disk if cached] memory: size of LZ4 package
Performance: LZMA decompression process + LZ4 compression process when downloading [+ process of reading from disk if cached]
* when downloading resource packs using WWW, WebRequest also has an overlay cache of 8*64kb to hold data from Socket
Summary-when using low-level loaded API in the game, there are the following suggestions:
1. Deploy the resource bundle in StreamingAssets-package it in BuildAssetBundleOptions.ChunkBasedCompression and load it with AssetBundle.LoadFromFileAsync, which provides the performance of data compression and fastest loading, and the memory overhead is equal to the read buffer.
2. When downloading the resource pack, use the default packaging option (LZMA compression), and use LoadFromCacheOrDownload/WebRequest to download and cache it. This will have the best compression ratio and AssetBundle.LoadFromFile loading performance for further loading.
3. Encryption package-- packaged with the BuildAssetBundleOptions.ChunkBasedCompression option and loaded with LoadFromMemoryAsync. (this is basically the only case where LoadFromMemoryAsync loading is used)
4. Custom compression-use the BuildAssetBundleOptions.UncompressedAssetBundle option to package, and after decompressing the resource package with a custom compression method, use AssetBundle.LoadFromFileAsync to load it.
Usually you should choose to load asynchronously, because this will not block the main thread and can effectively sort the load operations. never call synchronous and asynchronous functions at the same time, which may cause the main thread to pause.
IV. Compatibility
To support the new compression types, the format included in the AssetBundle resource pack has changed and provides the basis for further improvements. The Unity5 version still supports the Unity4 version of packaged resources, but does not support 2.x and 3.x versions of packaged resources.
This is the end of the article on "what is the way to compress and decompress AssetBundle?" Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "what is AssetBundle compression and decompression". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
1. Start the node start-dfs.sh of hadoop
© 2024 shulou.com SLNews company. All rights reserved.