1.2批量打包方法
using UnityEngine;
using UnityEditor;
using System.Collections;
public class ExportAssetSerielize : MonoBehaviour
{
[MenuItem("Custom Editor/Create AssetBundles Main")]
static void CreateAssetBundleMain()
{
//获取在project视图中选择的所有游戏对象
Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
//遍历所有的游戏对象
foreach(Object obj in SelectedAsset)
{
string sourcePath = AssetDatabase.GetAssetPath(obj);
string targetPath = Application.dataPath + @"/Prb/" + obj.name + ".assetbundle";
if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies))
{
Debug.Log(obj.name + "资源打包成功");
}
else
{
Debug.Log(obj.name + "资源打包失败");
}
}
AssetDatabase.Refresh();// 刷新编辑器
}
}