Version: 2022.3
언어: 한국어
에셋 번들의 전문적인 활용
에셋 번들로 패치

에셋 번들 압축

Use this page to learn about the AssetBundle compression formats and cache types that Unity supports.

AssetBundle compression formats

기본적으로 Unity는 LZMA 압축을 사용하여 에셋 번들을 생성하고, LZ4 압축을 사용하여 캐싱합니다. 이 섹션에서는 이 두 가지 압축 포맷에 대해 설명합니다.

Unity’s AssetBundle build pipeline creates AssetBundles with LZMA compression. This compression format is a stream of data representing the entire AssetBundle, which means that if you need to read an Asset from these archives, you must decompress the entire stream. This is the preferred format for AssetBundles downloaded from a Content Delivery Network (CDN), because the file sizes are smaller than those with LZ4 compression.

LZ4 compression is a chunk-based compression algorithm. If Unity needs to access an Asset from an LZ4 archive, it only needs to decompress and read the chunks that contain bytes of the requested Asset. This is the compression method that Unity uses in both of its AssetBundle caches. Use the BuildAssetBundleOptions.ChunkBasedCompression value when building AssetBundles to force LZ4(HC) compression.

Uncompressed AssetBundles that Unity builds when you use BuildAssetBundleOptions.UncompressedAssetBundle require no decompression, but occupy more disk space. Uncompressed AssetBundles are 16-byte aligned.

AssetBundle cache

To optimize the fetching, recompressing, and versioning of LZMA AssetBundles using WWW or UnityWebRequest (UWR), Unity maintains two caches:

  • The Memory Cache stores AssetBundles in UncompressedRuntime format in RAM.

  • 디스크 캐시는 페치된 에셋 번들을 뒤에서 설명할 압축 포맷으로 쓰기 가능한 미디어에 저장합니다.

메모리 캐시에 로드된 에셋 번들은 많은 양의 메모리를 소비합니다. 에셋 번들 콘텐츠에 자주 빠르게 액세스하려는 경우가 아니라면 메모리 캐시는 메모리 비용의 가치가 없습니다. 대신, 디스크 캐시를 사용하시기 바랍니다.

If you provide a version parameter to the UWR API, Unity stores your AssetBundle data in the Disk Cache. If you don’t provide a version parameter, Unity uses the Memory Cache. The version parameter can be either a version number or a hash. If Caching.compressionEnabled is set to true, Unity applies LZ4 compression when it writes AssetBundles to disk for all subsequent downloads. It doesn’t compress existing uncompressed data in the cache. If Caching.compressionEnabled is false, Unity applies no compression when it writes AssetBundles to disk.

Unity가 아카이브를 대상 포맷으로 다시 압축해야 하므로 캐싱된 LZMA 에셋 번들을 처음 로드할 때는 시간이 좀 더 걸립니다. 이후 로드는 캐싱된 버전을 사용합니다.

AssetBundle.LoadFromFile or AssetBundle.LoadFromFileAsync always use the Memory Cache for LZMA AssetBundles, so you should use the UWR API. If it’s not possible to use the UWR API, you can use AssetBundle.RecompressAssetBundleAsync to rewrite an LZMA AssetBundle on disk.

Note: WebGL doesn’t support LZMA compression for AssetBundles. Use LZ4 compression with AssetBundles on WebGL platforms. For more information, see Reduce load times with AssetBundles.

Internal testing shows significant difference in RAM usage between using the Disk Cache instead of the Memory Cache. You must weigh the trade-off between memory impact versus added disk space requirements and Asset instantiation time for your application.

에셋 번들의 전문적인 활용
에셋 번들로 패치
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961