ManifestBundleBuildTask.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections.Generic;
  2. using XGame.Editor.Asset;
  3. using XGame.Framework.Asset;
  4. namespace XGame.Editor.Build.AssetBundles
  5. {
  6. public class ManifestBundleBuildTask
  7. {
  8. private IBuildPipeline _buildPipeline;
  9. public ManifestBundleBuildTask(IBuildPipeline buildPipeline)
  10. {
  11. _buildPipeline = buildPipeline;
  12. }
  13. public bool Run()
  14. {
  15. var assetNames = new List<string>() { PathDefine.BundleManifestPath, PathDefine.SceneAssetBundleManifestPath, PathDefine.ReferenceManifestPath, PathDefine.ProductAssetManifestPath };
  16. var addressableNames = new List<string>() { Define.ASSET_BUNDLE_MANIFEST, Define.SCENE_BUNDLE_MANIFEST, Define.ASSET_REFERENCE_MANIFEST, Define.PRODUCT_ASSET_MANIFEST };
  17. if (System.IO.File.Exists(PathDefine.BuiltInAssetManifestPath))
  18. {
  19. assetNames.Add(PathDefine.BuiltInAssetManifestPath);
  20. addressableNames.Add(Define.BUILTIN_ASSET_MANIFEST);
  21. }
  22. var builds = new UnityEditor.AssetBundleBuild[]
  23. {
  24. new UnityEditor.AssetBundleBuild()
  25. {
  26. assetBundleName = Define.MANIFEST_BUNDLE_NAME,
  27. assetBundleVariant = Define.BUNDLE_VARIANT,
  28. assetNames = assetNames.ToArray(),
  29. addressableNames = addressableNames.ToArray(),
  30. }
  31. };
  32. return _buildPipeline.BuildAssetBundles(builds);
  33. }
  34. }
  35. }