using XGame.Framework.Asset; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace XGame.Editor.Build.AssetBundles { public static class AssetBundleManifestExt { /// /// 编辑器扩展方法 /// 返回所有bundle的FullName /// /// /// public static string[] GetAllBundleNames(this IAssetBundleManifest manifest) { if (manifest is CSharpAssetBundleManifest csBundleManifest) { var fileInfo = csBundleManifest.GetType().GetField("_bundleIdToNameMap", BindingFlags.NonPublic | BindingFlags.Instance); if (fileInfo != null) { var bundles = (Dictionary)fileInfo.GetValue(csBundleManifest); return bundles.Values.ToArray(); } } return null; } /// /// 编辑器扩展方法 /// 返回所有的bundleInfo /// /// /// public static AssetBundleInfo[] GetAllBundleInfos(this IAssetBundleManifest manifest) { if (manifest is CSharpAssetBundleManifest csBundleManifest) { var fileInfo = csBundleManifest.GetType().GetField("_bundleInfoMap", BindingFlags.NonPublic | BindingFlags.Instance); if (fileInfo != null) { var bundles = (Dictionary)fileInfo.GetValue(csBundleManifest); return bundles.Values.ToArray(); } } return null; } } }