using System; using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEditor.Build.Pipeline; using UnityEditor.Build.Pipeline.Interfaces; namespace YooAsset.Editor { public class ScriptableBuildParameters : BuildParameters { /// /// 压缩选项 /// public ECompressOption CompressOption = ECompressOption.Uncompressed; /// /// 禁止写入类型树结构(可以降低包体和内存并提高加载效率) /// public bool DisableWriteTypeTree = false; /// /// 忽略类型树变化 /// public bool IgnoreTypeTreeChanges = true; /// /// 生成代码防裁剪配置 /// public bool WriteLinkXML = true; /// /// 缓存服务器地址 /// public string CacheServerHost; /// /// 缓存服务器端口 /// public int CacheServerPort; /// /// 获取可编程构建管线的构建参数 /// public BundleBuildParameters GetBundleBuildParameters() { var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(BuildTarget); var pipelineOutputDirectory = GetPipelineOutputDirectory(); var buildParams = new BundleBuildParameters(BuildTarget, targetGroup, pipelineOutputDirectory); if (CompressOption == ECompressOption.Uncompressed) buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed; else if (CompressOption == ECompressOption.LZMA) buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA; else if (CompressOption == ECompressOption.LZ4) buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4; else throw new System.NotImplementedException(CompressOption.ToString()); if (DisableWriteTypeTree) buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree; buildParams.UseCache = true; buildParams.CacheServerHost = CacheServerHost; buildParams.CacheServerPort = CacheServerPort; buildParams.WriteLinkXML = WriteLinkXML; return buildParams; } } }