using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
public class CreateAssetBundle : MonoBehaviour
{
[MenuItem(“Custom/Create Object to It’s Single Bundle”)]
static void ExecuteSingleObjectCreateAssetBundle()
{
//清除缓存
Caching.CleanCache();
//获取Project视图中选择的所有游戏对象
Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
//生成AssetBundle保存目录
if (!Directory.Exists(Application.dataPath + “/StreamingAssets”))
{
Directory.CreateDirectory(Application.dataPath + “/StreamingAssets”);
}
//遍历所有游戏对象
foreach(Object _object in SelectedAsset)
{
string sourcePath = Application.dataPath + “/StreamingAssets/” + _object.name + “.assetbundle”;
#if UNITY_ANDROID
if(BuildPipeline.BuildAssetBundle(_object, null, sourcePath, BuildAssetBundle