资源包构建选项。
这些标志允许您在调用 BuildPipeline.BuildAssetBundles 时配置选项。
其他资源:AssetBundle,BuildPipeline.BuildAssetBundles
//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 “Strict Mode”. Click these menu items to build an AssetBundle into a folder with either no extra build options, or a strict build.
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 (Strict Mode) in the new Build Asset Bundles menu [MenuItem("Build Asset Bundles/Strict Mode")] static void BuildABsStrict() { //Build the AssetBundles in strict mode (build fails if any errors are detected) BuildPipeline.BuildAssetBundles("Assets/MyAssetBuilds", BuildAssetBundleOptions.StrictMode, BuildTarget.StandaloneOSX); } }
无 | 不使用任何特殊选项构建资源包。 |
UncompressedAssetBundle | 创建资源包时不压缩数据。 |
DisableWriteTypeTree | 不包含资源包中的类型信息。 |
ForceRebuildAssetBundle | 强制重新构建资源包。 |
IgnoreTypeTreeChanges | 在执行增量构建检查时忽略类型树更改。 |
AppendHashToAssetBundleName | 将哈希值追加到资源包名称。 |
ChunkBasedCompression | 创建资源包时使用基于块的 LZ4 压缩。 |
StrictMode | 如果在构建过程中报告任何错误,则不允许构建成功。 |
DryRunBuild | 进行一次试运行构建。 |
DisableLoadAssetByFileName | 禁用资源包按文件名加载资源。 |
DisableLoadAssetByFileNameWithExtension | 禁用资源包按带扩展名的文件名加载资源。 |
AssetBundleStripUnityVersion | 在构建过程中删除存档文件和序列化文件头中的 Unity 版本号。 |
UseContentHash | 使用资源包的内容来计算哈希值。此功能始终启用。 |
RecurseDependencies | 当需要递归计算资源包依赖项时使用,例如当您具有匹配类型可脚本化对象的依赖项链时。 |