Sup guys,
I'm trying to update my project from Unity 4 to version 5, I'm just having trouble now to update the BuildAssetBundle, I read the new document, but found it too abstract for understanding.
Could someone help me to update the code? And explain if possible?
Thank you very much!
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 + ".unity3d";
BuildPipeline.BuildAssetBundle(t,null,bundlepath, option);
}
}
}
}
↧