您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
27 行
1.2 KiB
27 行
1.2 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
namespace MetaCity.BundleKit.Editor.VRM
|
|
{
|
|
public class VRMMaterialBundleExporter
|
|
{
|
|
public static (List<BuildCatalog>,AssetBundleManifest) BuildMaterialBundle(string vrmModelName,IEnumerable<object> materials,List<BuildCatalog> catalogs)
|
|
{
|
|
var platform = EditorUserBuildSettings.activeBuildTarget;
|
|
|
|
List<AssetBundleBuild> curBundleBuild = new List<AssetBundleBuild>();
|
|
//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);
|
|
}
|
|
}
|
|
}
|