此篇用来记录
第一种包名打包方式:
[MenuItem ("MyAssets/packageModle004")]
static void AssetsBundleFunction()
{
string abFile = "Assets/StreamingAssets";
if (!Directory .Exists(abFile))
{
Directory.CreateDirectory(abFile);
}
BuildPipeline.BuildAssetBundles(abFile, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
}
第二种分割打包:
[MenuItem("MyAssets/Creat AssetBundle By themselves")]
public static void CreatAssetBundleThemelves()
{
Object[] selects = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
foreach (var item in selects)
{
string path = AssetDatabase.GetAssetPath(item);
AssetImporter.GetAtPath(path).assetBundleName = item.name;
string targetPath = "Assets/StreamingAssets";
if (BuildPipeline.BuildAssetBundles(targetPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64))
{
Debug.Log(item.name + "is packed successfully");
}
else
{
Debug.Log(item.name + "is packed failly!");
}
}
}