/// <summary>
        /// 创建补丁清单文件到输出目录
        /// </summary>
        private void CreatePatchManifestFile(AssetBundleBuilder.BuildParametersContext buildParameters,
                                             BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
        {
            int resourceVersion = buildParameters.Parameters.BuildVersion;

            // 创建新补丁清单
            PatchManifest patchManifest = new PatchManifest();

            patchManifest.EnableAddressable = buildParameters.Parameters.EnableAddressable;
            patchManifest.ResourceVersion   = buildParameters.Parameters.BuildVersion;
            patchManifest.BuildinTags       = buildParameters.Parameters.BuildinTags;
            patchManifest.BundleList        = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext);
            patchManifest.AssetList         = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest);

            // 创建补丁清单文件
            string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";

            BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
            PatchManifest.Serialize(manifestFilePath, patchManifest);

            // 创建补丁清单哈希文件
            string manifestHashFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
            string manifestHash         = HashUtility.FileMD5(manifestFilePath);

            BuildRunner.Log($"创建补丁清单哈希文件:{manifestHashFilePath}");
            FileUtility.CreateFile(manifestHashFilePath, manifestHash);

            // 创建静态版本文件
            string staticVersionFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
            string staticVersion         = resourceVersion.ToString();

            BuildRunner.Log($"创建静态版本文件:{staticVersionFilePath}");
            FileUtility.CreateFile(staticVersionFilePath, staticVersion);
        }
        /// <summary>
        /// 加载补丁清单文件
        /// </summary>
        internal static PatchManifest LoadPatchManifestFile(string fileDirectory, int resourceVersion)
        {
            string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";

            if (File.Exists(filePath) == false)
            {
                throw new System.Exception($"Not found patch manifest file : {filePath}");
            }

            string jsonData = FileUtility.ReadFile(filePath);

            return(PatchManifest.Deserialize(jsonData));
        }
Beispiel #3
0
        private void CopyBuildinFilesToStreaming(string pipelineOutputDirectory, int buildVersion)
        {
            // 加载补丁清单
            PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildVersion);

            // 拷贝文件列表
            foreach (var patchBundle in patchManifest.BundleList)
            {
                if (patchBundle.IsBuildin == false)
                {
                    continue;
                }

                string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
                string destPath   = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{patchBundle.Hash}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝清单文件
            {
                string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
                string destPath   = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝清单哈希文件
            {
                string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
                string destPath   = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝静态版本文件
            {
                string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
                string destPath   = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettings.VersionFileName}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 刷新目录
            AssetDatabase.Refresh();
            BuildRunner.Log($"内置文件拷贝完成:{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}");
        }
        /// <summary>
        /// 拷贝补丁文件到补丁包目录
        /// </summary>
        private void CopyPatchFiles(AssetBundleBuilder.BuildParametersContext buildParameters)
        {
            int    resourceVersion  = buildParameters.Parameters.BuildVersion;
            string packageDirectory = buildParameters.GetPackageDirectory();

            BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageDirectory}");

            // 拷贝Report文件
            {
                string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion);
                string sourcePath     = $"{buildParameters.PipelineOutputDirectory}/{reportFileName}";
                string destPath       = $"{packageDirectory}/{reportFileName}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝补丁清单文件
            {
                string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
                string destPath   = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝补丁清单哈希文件
            {
                string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
                string destPath   = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝静态版本文件
            {
                string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
                string destPath   = $"{packageDirectory}/{YooAssetSettings.VersionFileName}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝UnityManifest序列化文件
            {
                string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
                string destPath   = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝UnityManifest文本文件
            {
                string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
                string destPath   = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
                EditorTools.CopyFile(sourcePath, destPath, true);
            }

            // 拷贝所有补丁文件
            int           progressValue       = 0;
            PatchManifest patchManifest       = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
            int           patchFileTotalCount = patchManifest.BundleList.Count;

            foreach (var patchBundle in patchManifest.BundleList)
            {
                string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{patchBundle.BundleName}";
                string destPath   = $"{packageDirectory}/{patchBundle.Hash}";
                EditorTools.CopyFile(sourcePath, destPath, true);
                EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
            }
            EditorTools.ClearProgressBar();
        }
Beispiel #5
0
        /// <summary>
        /// 模拟构建
        /// </summary>
        public static void SimulateBuild()
        {
            string          defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
            BuildParameters buildParameters   = new BuildParameters();

            buildParameters.OutputRoot        = defaultOutputRoot;
            buildParameters.BuildTarget       = EditorUserBuildSettings.activeBuildTarget;
            buildParameters.BuildMode         = EBuildMode.SimulateBuild;
            buildParameters.BuildVersion      = 999;
            buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;

            AssetBundleBuilder builder = new AssetBundleBuilder();
            bool buildResult           = builder.Run(buildParameters);

            if (buildResult)
            {
                string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
                _manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.SimulateBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";
            }
            else
            {
                _manifestFilePath = null;
            }
        }