using System.IO;
using UnityEditor;
using UnityEngine;
public class BuildAssetBundlesFromDirectoryALL
{
[MenuItem("Assets/Create AssetBunldes ALL")]
static void CreateAssetBunldesALL()
{
Caching.CleanCache();
//BuildAssetBundleOptions m_option = BuildAssetBundleOptions.CollectDependencies | // 收集所有依赖关系
// BuildAssetBundleOptions.DeterministicAssetBundle;
Object[] SelectedAsset = Selection.GetFiltered(typeof (Object), SelectionMode.DeepAssets);
foreach (Object obj in SelectedAsset)
{
Debug.Log("Create AssetBunldes name :" + obj);
}
string Path = Application.dataPath + "/StreamingAssets/"+SelectedAsset[0].name+".assetbundle";
//打包资源
// (BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android))
//这里注意第二个参数就行
if (BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android))//(BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android))
{
Debug.Log("打包成功");
AssetDatabase.Refresh();
}
else
{
Debug.Log("打包失败");
}
}
}
using UnityEditor;
using UnityEngine;
public class BuildAssetBundlesFromDirectoryALL
{
[MenuItem("Assets/Create AssetBunldes ALL")]
static void CreateAssetBunldesALL()
{
Caching.CleanCache();
//BuildAssetBundleOptions m_option = BuildAssetBundleOptions.CollectDependencies | // 收集所有依赖关系
// BuildAssetBundleOptions.DeterministicAssetBundle;
Object[] SelectedAsset = Selection.GetFiltered(typeof (Object), SelectionMode.DeepAssets);
foreach (Object obj in SelectedAsset)
{
Debug.Log("Create AssetBunldes name :" + obj);
}
string Path = Application.dataPath + "/StreamingAssets/"+SelectedAsset[0].name+".assetbundle";
//打包资源
// (BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android))
//这里注意第二个参数就行
if (BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android))//(BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android))
{
Debug.Log("打包成功");
AssetDatabase.Refresh();
}
else
{
Debug.Log("打包失败");
}
}
}