diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs index 92b6518..f86beb6 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs @@ -15,7 +15,7 @@ namespace YooAsset.Editor /// /// 构建资源包 /// - public BuildResult Run(BuildParameters buildParameters, List buildPipeline) + public BuildResult Run(BuildParameters buildParameters, List buildPipeline, bool enableLog) { // 检测构建参数是否为空 if (buildParameters == null) @@ -33,9 +33,10 @@ namespace YooAsset.Editor _buildContext.SetContextObject(buildParametersContext); // 初始化日志 - BuildLogger.InitLogger(buildParameters.EnableLog); + BuildLogger.InitLogger(enableLog); // 执行构建流程 + Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}"); var buildResult = BuildRunner.Run(buildPipeline, _buildContext); if (buildResult.Success) { @@ -51,62 +52,5 @@ namespace YooAsset.Editor return buildResult; } - - /// - /// 构建资源包 - /// - public BuildResult Run(BuildParameters buildParameters) - { - var buildPipeline = GetDefaultBuildPipeline(buildParameters.BuildPipeline); - return Run(buildParameters, buildPipeline); - } - - /// - /// 获取默认的构建流程 - /// - private List GetDefaultBuildPipeline(EBuildPipeline buildPipeline) - { - // 获取任务节点的属性集合 - if (buildPipeline == EBuildPipeline.BuiltinBuildPipeline) - { - List pipeline = new List - { - new TaskPrepare(), //前期准备工作 - new TaskGetBuildMap(), //获取构建列表 - new TaskBuilding(), //开始执行构建 - new TaskCopyRawFile(), //拷贝原生文件 - new TaskVerifyBuildResult(), //验证构建结果 - new TaskEncryption(), //加密资源文件 - new TaskUpdateBundleInfo(), //更新资源包信息 - new TaskCreateManifest(), //创建清单文件 - new TaskCreateReport(), //创建报告文件 - new TaskCreatePackage(), //制作包裹 - new TaskCopyBuildinFiles(), //拷贝内置文件 - }; - return pipeline; - } - else if (buildPipeline == EBuildPipeline.ScriptableBuildPipeline) - { - List pipeline = new List - { - new TaskPrepare(), //前期准备工作 - new TaskGetBuildMap(), //获取构建列表 - new TaskBuilding_SBP(), //开始执行构建 - new TaskCopyRawFile(), //拷贝原生文件 - new TaskVerifyBuildResult_SBP(), //验证构建结果 - new TaskEncryption(), //加密资源文件 - new TaskUpdateBundleInfo(), //更新补丁信息 - new TaskCreateManifest(), //创建清单文件 - new TaskCreateReport(), //创建报告文件 - new TaskCreatePackage(), //制作补丁包 - new TaskCopyBuildinFiles(), //拷贝内置文件 - }; - return pipeline; - } - else - { - throw new NotImplementedException(); - } - } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs index 35d30b4..050b937 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs @@ -20,7 +20,7 @@ namespace YooAsset.Editor /// /// 获取流文件夹路径 /// - public static string GetDefaultStreamingAssetsRoot() + public static string GetStreamingAssetsRoot() { return $"{Application.dataPath}/StreamingAssets/{YooAssetSettings.DefaultYooFolderName}/"; } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs index 3d93766..77bcc6d 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs @@ -1,49 +1,93 @@ using System; using UnityEngine; +using UnityEditor; namespace YooAsset.Editor { - [CreateAssetMenu(fileName = "AssetBundleBuilderSetting", menuName = "YooAsset/Create AssetBundle Builder Settings")] - public class AssetBundleBuilderSetting : ScriptableObject + public static class AssetBundleBuilderSetting { - /// - /// 构建管线 - /// - public EBuildPipeline BuildPipeline = EBuildPipeline.BuiltinBuildPipeline; + // EBuildPipeline + public static EBuildPipeline GetPackageBuildPipeline(string packageName) + { + string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}"; + return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline); + } + public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline) + { + string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}"; + EditorPrefs.SetInt(key, (int)buildPipeline); + } - /// - /// 构建模式 - /// - public EBuildMode BuildMode = EBuildMode.ForceRebuild; + // EBuildMode + public static EBuildMode GetPackageBuildMode(string packageName, EBuildPipeline buildPipeline) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}"; + return (EBuildMode)EditorPrefs.GetInt(key, (int)EBuildMode.ForceRebuild); + } + public static void SetPackageBuildMode(string packageName, EBuildPipeline buildPipeline, EBuildMode buildMode) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}"; + EditorPrefs.SetInt(key, (int)buildMode); + } - /// - /// 构建的包裹名称 - /// - public string BuildPackage = string.Empty; + // ECompressOption + public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}"; + return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4); + } + public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}"; + EditorPrefs.SetInt(key, (int)compressOption); + } - /// - /// 压缩方式 - /// - public ECompressOption CompressOption = ECompressOption.LZ4; + // EFileNameStyle + public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}"; + return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName); + } + public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}"; + EditorPrefs.SetInt(key, (int)fileNameStyle); + } - /// - /// 输出文件名称样式 - /// - public EOutputNameStyle OutputNameStyle = EOutputNameStyle.HashName; + // EBuildinFileCopyOption + public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}"; + return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None); + } + public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}"; + EditorPrefs.SetInt(key, (int)buildinFileCopyOption); + } - /// - /// 首包资源文件的拷贝方式 - /// - public ECopyBuildinFileOption CopyBuildinFileOption = ECopyBuildinFileOption.None; + // BuildFileCopyParams + public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams"; + return EditorPrefs.GetString(key, string.Empty); + } + public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams"; + EditorPrefs.SetString(key, buildinFileCopyParams); + } - /// - /// 首包资源文件的标签集合 - /// - public string CopyBuildinFileTags = string.Empty; - - /// - /// 加密类名称 - /// - public string EncyptionClassName = string.Empty; + // EncyptionClassName + public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName"; + return EditorPrefs.GetString(key, string.Empty); + } + public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName) + { + string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName"; + EditorPrefs.SetString(key, encyptionClassName); + } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs deleted file mode 100644 index 353931b..0000000 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace YooAsset.Editor -{ - public class AssetBundleBuilderSettingData - { - private static AssetBundleBuilderSetting _setting = null; - public static AssetBundleBuilderSetting Setting - { - get - { - if (_setting == null) - LoadSettingData(); - return _setting; - } - } - - /// - /// 配置数据是否被修改 - /// - public static bool IsDirty { set; get; } = false; - - /// - /// 加载配置文件 - /// - private static void LoadSettingData() - { - _setting = SettingLoader.LoadSettingData(); - } - - /// - /// 存储文件 - /// - public static void SaveFile() - { - if (Setting != null) - { - IsDirty = false; - EditorUtility.SetDirty(Setting); - AssetDatabase.SaveAssets(); - Debug.Log($"{nameof(AssetBundleBuilderSetting)}.asset is saved!"); - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs index 450e31e..3d930d7 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs @@ -18,22 +18,14 @@ namespace YooAsset.Editor window.minSize = new Vector2(800, 600); } - private BuildTarget _buildTarget; - private List _encryptionServicesClassTypes; - private List _encryptionServicesClassNames; - private List _buildPackageNames; + private string _buildPackage; + private EBuildPipeline _buildPipeline; + + private Toolbar _toolbar; + private ToolbarMenu _packageMenu; + private ToolbarMenu _pipelineMenu; + private VisualElement _container; - private Button _saveButton; - private TextField _buildOutputField; - private EnumField _buildPipelineField; - private EnumField _buildModeField; - private TextField _buildVersionField; - private PopupField _buildPackageField; - private PopupField _encryptionField; - private EnumField _compressionField; - private EnumField _outputNameStyleField; - private EnumField _copyBuildinFileOptionField; - private TextField _copyBuildinFileTagsField; public void CreateGUI() { @@ -47,276 +39,76 @@ namespace YooAsset.Editor return; visualAsset.CloneTree(root); + _toolbar = root.Q("Toolbar"); + _container = root.Q("Container"); - // 配置保存按钮 - _saveButton = root.Q