diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs index eb4b2f5..92b6518 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs @@ -23,20 +23,7 @@ namespace YooAsset.Editor // 检测构建参数是否为空 if (buildPipeline.Count == 0) - throw new Exception($"Build pipeline is empty !"); - - // 检测可编程构建管线参数 - if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline) - { - if (buildParameters.SBPParameters == null) - throw new Exception($"{nameof(BuildParameters.SBPParameters)} is null !"); - - if (buildParameters.BuildMode == EBuildMode.DryRunBuild) - throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !"); - - if (buildParameters.BuildMode == EBuildMode.ForceRebuild) - throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !"); - } + throw new Exception($"Build pipeline is empty !"); // 清空旧数据 _buildContext.ClearAllContext(); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs index ab0f933..35d30b4 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs @@ -11,7 +11,7 @@ namespace YooAsset.Editor /// /// 获取默认的输出根路录 /// - public static string GetDefaultOutputRoot() + public static string GetDefaultBuildOutputRoot() { string projectPath = EditorTools.GetProjectPath(); return $"{projectPath}/Bundles"; @@ -20,43 +20,9 @@ namespace YooAsset.Editor /// /// 获取流文件夹路径 /// - public static string GetStreamingAssetsFolderPath() + public static string GetDefaultStreamingAssetsRoot() { - return $"{Application.dataPath}/StreamingAssets/{YooAssetSettings.StreamingAssetsBuildinFolder}/"; - } - - /// - /// 清空流文件夹 - /// - public static void ClearStreamingAssetsFolder() - { - string streamingFolderPath = GetStreamingAssetsFolderPath(); - EditorTools.ClearFolder(streamingFolderPath); - } - - /// - /// 删除流文件夹内无关的文件 - /// 删除.manifest文件和.meta文件 - /// - public static void DeleteStreamingAssetsIgnoreFiles() - { - string streamingFolderPath = GetStreamingAssetsFolderPath(); - if (Directory.Exists(streamingFolderPath)) - { - string[] files = Directory.GetFiles(streamingFolderPath, "*.manifest", SearchOption.AllDirectories); - foreach (var file in files) - { - FileInfo info = new FileInfo(file); - info.Delete(); - } - - files = Directory.GetFiles(streamingFolderPath, "*.meta", SearchOption.AllDirectories); - foreach (var item in files) - { - FileInfo info = new FileInfo(item); - info.Delete(); - } - } + return $"{Application.dataPath}/StreamingAssets/{YooAssetSettings.DefaultYooFolderName}/"; } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs index 3912f94..450e31e 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs @@ -63,7 +63,7 @@ namespace YooAsset.Editor _encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.Name).ToList(); // 输出目录 - string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot(); + string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); _buildOutputField = root.Q("BuildOutput"); _buildOutputField.SetValueWithoutNotify(defaultOutputRoot); _buildOutputField.SetEnabled(false); @@ -266,9 +266,9 @@ namespace YooAsset.Editor /// private void ExecuteBuild() { - string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot(); BuildParameters buildParameters = new BuildParameters(); - buildParameters.OutputRoot = defaultOutputRoot; + buildParameters.StreamingAssetsRoot = AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot(); + buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); buildParameters.BuildTarget = _buildTarget; buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline; buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs index 9a89843..c7adc44 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs @@ -11,9 +11,9 @@ namespace YooAsset.Editor public static string SimulateBuild(string packageName) { Debug.Log($"Begin to create simulate package : {packageName}"); - string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot(); BuildParameters buildParameters = new BuildParameters(); - buildParameters.OutputRoot = defaultOutputRoot; + buildParameters.StreamingAssetsRoot = AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot(); + buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget; buildParameters.BuildMode = EBuildMode.SimulateBuild; buildParameters.PackageName = packageName; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs index 40b6a62..cef251a 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs @@ -37,9 +37,14 @@ namespace YooAsset.Editor /// - /// 输出的根目录 + /// 内置资源的根目录 /// - public string OutputRoot; + public string StreamingAssetsRoot; + + /// + /// 构建输出的根目录 + /// + public string BuildOutputRoot; /// /// 构建的平台 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs index 5774c93..e4bb864 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs @@ -9,6 +9,8 @@ namespace YooAsset.Editor { private string _pipelineOutputDirectory = string.Empty; private string _packageOutputDirectory = string.Empty; + private string _packageRootDirectory = string.Empty; + private string _streamingAssetsDirectory = string.Empty; /// /// 构建参数 @@ -29,23 +31,47 @@ namespace YooAsset.Editor { if (string.IsNullOrEmpty(_pipelineOutputDirectory)) { - _pipelineOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{YooAssetSettings.OutputFolderName}"; + _pipelineOutputDirectory = $"{Parameters.BuildOutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{YooAssetSettings.OutputFolderName}"; } return _pipelineOutputDirectory; } /// - /// 获取本次构建的补丁目录 + /// 获取本次构建的补丁输出目录 /// public string GetPackageOutputDirectory() { if (string.IsNullOrEmpty(_packageOutputDirectory)) { - _packageOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{Parameters.PackageVersion}"; + _packageOutputDirectory = $"{Parameters.BuildOutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{Parameters.PackageVersion}"; } return _packageOutputDirectory; } + /// + /// 获取本次构建的补丁根目录 + /// + public string GetPackageRootDirectory() + { + if (string.IsNullOrEmpty(_packageRootDirectory)) + { + _packageRootDirectory = $"{Parameters.BuildOutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}"; + } + return _packageRootDirectory; + } + + /// + /// 获取内置资源的目录 + /// + public string GetStreamingAssetsDirectory() + { + if (string.IsNullOrEmpty(_streamingAssetsDirectory)) + { + _streamingAssetsDirectory = $"{Parameters.StreamingAssetsRoot}/{Parameters.PackageName}"; + } + return _streamingAssetsDirectory; + } + /// /// 获取内置构建管线的构建选项 /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs index 4f9d1e5..645040d 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs @@ -30,7 +30,7 @@ namespace YooAsset.Editor { ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption; string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory(); - string streamingAssetsDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath(); + string streamingAssetsDirectory = buildParametersContext.GetStreamingAssetsDirectory(); string buildPackageName = buildParametersContext.Parameters.PackageName; string buildPackageVersion = buildParametersContext.Parameters.PackageVersion; @@ -40,7 +40,7 @@ namespace YooAsset.Editor // 清空流目录 if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags) { - AssetBundleBuilderHelper.ClearStreamingAssetsFolder(); + EditorTools.ClearFolder(streamingAssetsDirectory); } // 拷贝补丁清单文件 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs index e9cba15..2c32d93 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs @@ -147,17 +147,17 @@ namespace YooAsset.Editor private void RemoveZeroReferenceAssets(List allCollectAssetInfos) { // 1. 检测是否任何存在依赖资源 - bool hasAnyDependAsset = false; + bool hasAnyDependCollector = false; foreach (var collectAssetInfo in allCollectAssetInfos) { var collectorType = collectAssetInfo.CollectorType; if (collectorType == ECollectorType.DependAssetCollector) { - hasAnyDependAsset = true; + hasAnyDependCollector = true; break; } } - if (hasAnyDependAsset == false) + if (hasAnyDependCollector == false) return; // 2. 获取所有主资源的依赖资源集合 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs index 46a8120..d28c250 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs @@ -16,11 +16,27 @@ namespace YooAsset.Editor // 检测构建参数合法性 if (buildParameters.BuildTarget == BuildTarget.NoTarget) - throw new Exception("请选择目标平台"); + throw new Exception("请选择目标平台!"); if (string.IsNullOrEmpty(buildParameters.PackageName)) - throw new Exception("包裹名称不能为空"); + throw new Exception("包裹名称不能为空!"); if (string.IsNullOrEmpty(buildParameters.PackageVersion)) - throw new Exception("包裹版本不能为空"); + throw new Exception("包裹版本不能为空!"); + if (string.IsNullOrEmpty(buildParameters.BuildOutputRoot)) + throw new Exception("构建输出的根目录为空!"); + if (string.IsNullOrEmpty(buildParameters.StreamingAssetsRoot)) + throw new Exception("内置资源根目录为空!"); + + if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline) + { + if (buildParameters.SBPParameters == null) + throw new Exception($"{nameof(BuildParameters.SBPParameters)} is null !"); + + if (buildParameters.BuildMode == EBuildMode.DryRunBuild) + throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !"); + + if (buildParameters.BuildMode == EBuildMode.ForceRebuild) + throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !"); + } if (buildParameters.BuildMode != EBuildMode.SimulateBuild) { @@ -72,11 +88,10 @@ namespace YooAsset.Editor if (buildParameters.BuildMode == EBuildMode.ForceRebuild) { - // 删除总目录 - string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.PackageName}"; - if (EditorTools.DeleteDirectory(platformDirectory)) + string packageRootDirectory = buildParametersContext.GetPackageRootDirectory(); + if (EditorTools.DeleteDirectory(packageRootDirectory)) { - BuildLogger.Log($"删除平台总目录:{platformDirectory}"); + BuildLogger.Log($"删除包裹目录:{packageRootDirectory}"); } }