AssetBundleSimulateBuilder.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using UnityEditor;
  2. namespace YooAsset.Editor
  3. {
  4. public static class AssetBundleSimulateBuilder
  5. {
  6. private static string _manifestFilePath = string.Empty;
  7. /// <summary>
  8. /// 模拟构建
  9. /// </summary>
  10. public static void SimulateBuild()
  11. {
  12. string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
  13. BuildParameters buildParameters = new BuildParameters();
  14. buildParameters.OutputRoot = defaultOutputRoot;
  15. buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
  16. buildParameters.BuildMode = EBuildMode.SimulateBuild;
  17. buildParameters.BuildVersion = 999;
  18. buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
  19. AssetBundleBuilder builder = new AssetBundleBuilder();
  20. var buildResult = builder.Run(buildParameters);
  21. if (buildResult.Success)
  22. {
  23. string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
  24. _manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.SimulateBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";
  25. }
  26. else
  27. {
  28. _manifestFilePath = null;
  29. }
  30. }
  31. /// <summary>
  32. /// 获取构建的补丁清单路径
  33. /// </summary>
  34. public static string GetPatchManifestPath()
  35. {
  36. return _manifestFilePath;
  37. }
  38. }
  39. }