版本: Unity 6 (6000.0)
语言英语
  • C#

BuildAssetBundleOptions.ChunkBasedCompression

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法接受所有提交内容,但我们会阅读用户提出的每项建议,并在适用的情况下进行更新。

关闭

提交失败

由于某种原因,您的建议更改无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

描述

在创建 AssetBundle 时使用基于块的 LZ4 压缩。

当使用基于块的压缩时,AssetBundle 的内容将被分解成单独的段,这些段将使用CompressionType.Lz4HC 算法独立压缩。生成的档案通常比默认使用的完整文件压缩更大,但使用这种格式构建的 AssetBundle 可以增量加载,例如,无需将完整内容解压缩到内存中。这是 AssetBundle 缓存中存储的 AssetBundle 使用的默认格式。

其他资源:AssetBundles 压缩BuildCompressionCompressionTypeArchiveHandle.CompressionCachingBuildAssetBundleOptions.UncompressedAssetBundleBuildOptions.CompressWithLz4

//Create a folder (right click in the Assets folder and go to Create>Folder), and name it “Editor” if it doesn’t already exist
//Place this script in the Editor folder

//This script creates a new Menu named “Build Asset” and new options within the menu named “Normal” and “Chunk Based Compression”. Click these menu items to build an AssetBundle.

using UnityEngine; using UnityEditor;

public class Example { //Creates a new menu (Build Asset Bundles) and item (Normal) in the Editor [MenuItem("Build Asset Bundles/Normal")] static void BuildABsNone() { //Build AssetBundles with no special options //They will be written in the custom folder ("MyAssetBuilds") which needs to exist prior to this call. BuildPipeline.BuildAssetBundles("Assets/MyAssetBuilds", BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX); }

//Creates a new item (Chunk Based Compression) in the new Build Asset Bundles menu [MenuItem("Build Asset Bundles/Chunk Based Compression")] static void BuildABsChunk() { //Build the AssetBundles in this mode BuildPipeline.BuildAssetBundles("Assets/MyAssetBuilds", BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneOSX); } }