using System; using UnityEditor.Build.Content; using UnityEditor.Build.Pipeline.Interfaces; using UnityEditor.Build.Pipeline.Utilities; using UnityEditor.Build.Player; using UnityEngine; namespace UnityEditor.Build.Pipeline { #if UNITY_2018_3_OR_NEWER using BuildCompression = UnityEngine.BuildCompression; #else using BuildCompression = UnityEditor.Build.Content.BuildCompression; #endif /// /// Basic implementation of IBuildParameters. Stores the set of parameters passed into the Scriptable Build Pipeline. /// /// [Serializable] public class BuildParameters : IBuildParameters { /// public BuildTarget Target { get; set; } /// public BuildTargetGroup Group { get; set; } /// public ContentBuildFlags ContentBuildFlags { get; set; } /// public TypeDB ScriptInfo { get; set; } /// public ScriptCompilationOptions ScriptOptions { get; set; } /// /// Default compression option to use for all built content files /// public BuildCompression BundleCompression { get; set; } /// /// Final output location where built content will be written. /// public string OutputFolder { get; set; } string m_TempOutputFolder; /// public string TempOutputFolder { get { return m_TempOutputFolder; } set { if (string.IsNullOrEmpty(value)) throw new ArgumentException("Argument cannot be null or empty.", "value"); m_TempOutputFolder = value; } } string m_ScriptOutputFolder; /// public string ScriptOutputFolder { get { return m_ScriptOutputFolder; } set { if (string.IsNullOrEmpty(value)) throw new ArgumentException("Argument cannot be null or empty.", "value"); m_ScriptOutputFolder = value; } } /// public bool UseCache { get; set; } /// public string CacheServerHost { get; set; } /// public int CacheServerPort { get; set; } /// public bool WriteLinkXML { get; set; } #if NONRECURSIVE_DEPENDENCY_DATA /// public bool NonRecursiveDependencies { get; set; } #endif internal BuildParameters() {} /// /// Default constructor, requires the target, group and output parameters at minimum for a successful build. /// /// The target for building content. /// The group for building content. /// The final output location for built content. public BuildParameters(BuildTarget target, BuildTargetGroup group, string outputFolder) { if (string.IsNullOrEmpty(outputFolder)) throw new ArgumentException("Argument cannot be null or empty.", "outputFolder"); Target = target; Group = group; // TODO: Validate target & group ScriptInfo = null; ScriptOptions = ScriptCompilationOptions.None; #if UNITY_2018_3_OR_NEWER BundleCompression = BuildCompression.LZMA; #else BundleCompression = BuildCompression.DefaultLZMA; #endif OutputFolder = outputFolder; TempOutputFolder = ContentPipeline.kTempBuildPath; ScriptOutputFolder = ContentPipeline.kScriptBuildPath; UseCache = true; CacheServerPort = 8126; if (ScriptableBuildPipeline.UseBuildCacheServer) { CacheServerHost = ScriptableBuildPipeline.CacheServerHost; CacheServerPort = ScriptableBuildPipeline.CacheServerPort; } WriteLinkXML = false; #if NONRECURSIVE_DEPENDENCY_DATA && UNITY_2021_1_OR_NEWER NonRecursiveDependencies = true; #endif } /// public virtual BuildSettings GetContentBuildSettings() { return new BuildSettings { group = Group, target = Target, typeDB = ScriptInfo, buildFlags = ContentBuildFlags }; } /// public virtual ScriptCompilationSettings GetScriptCompilationSettings() { return new ScriptCompilationSettings { group = Group, target = Target, options = ScriptOptions }; } /// public virtual string GetOutputFilePathForIdentifier(string identifier) { return string.Format("{0}/{1}", OutputFolder, identifier); } /// public virtual BuildCompression GetCompressionForIdentifier(string identifier) { return BundleCompression; } } /// /// Stores the set of parameters passed into Scriptable Build Pipeline when building bundles. /// [Serializable] public class BundleBuildParameters : BuildParameters, IBundleBuildParameters { internal BundleBuildParameters() {} /// public BundleBuildParameters(BuildTarget target, BuildTargetGroup group, string outputFolder) : base(target, group, outputFolder) { #if UNITY_2021_1_OR_NEWER ContiguousBundles = true; #endif } /// public bool AppendHash { get; set; } /// public bool ContiguousBundles { get; set; } /// public bool DisableVisibleSubAssetRepresentations { get; set; } } }