using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; namespace MetaCity.BundleKit.Editor.VRM { public class VRMMaterialBundleExporter { public static (List,AssetBundleManifest) BuildMaterialBundle(string vrmModelName,IEnumerable materials,List catalogs) { var platform = EditorUserBuildSettings.activeBuildTarget; List curBundleBuild = new List(); //Select referenced materials to one bundle var resourcePaths=materials.Select(x=>AssetDatabase.GetAssetPath(x as Material)).ToList(); var builder = Utilities.CreateNewAssetBundleBuild(vrmModelName, resourcePaths.ToArray()); curBundleBuild.Add(builder); var manifest = BuildPipeline.BuildAssetBundles(Constants.AvatarBundleFolderPath, curBundleBuild.ToArray(), BuildAssetBundleOptions.None, platform); var catalog = CatalogUtilities.CreateMaterialCatalog(platform, vrmModelName, manifest); if (catalog != null) { catalogs.Add(catalog); } return (catalogs,manifest); } } }