依然是Assets/Scripts/Tools/Editor目录下
BytesAdd.cs
这个文件的代码有错,估计没使用了,又没改吧。
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections;
public class BytesAdd{
[@MenuItem("BoLong/Build AssetBundles/From bytes of Files")]
static void ExportAssetBundles(){
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
BuildAssetBundleOptions option = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets;
if(path.Length !=0 )
{
path = path.Replace("Assets/","");
string [] fileEntries = Directory.GetFiles(Application.dataPath + "/" + path);
foreach(string fileName in fileEntries){
string filePath = fileName;
int index = filePath.LastIndexOf("/");
filePath = filePath.Substring(index);
int indexp = path.LastIndexOf("/");
path = path.Substring(0,indexp);
string localPath = "Assets/" + path;
if(index > 0)
{
localPath += filePath;
}
Object t =AssetDatabase.LoadMainAssetAtPath(localPath);
if(t != null)
{
string bundlepath = "Assets/" + path + "/" +t.name + ".bytes";
BuildPipeline.BuildAssetBundle(t,null,bundlepath, option);
}
}
}
}
}