脚本应该放在Editor文件夹下
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor; public class BuildAssetBundle { [MenuItem("BuildAB/BuildABToWin64/LZMA(体积小,加载慢)")]
private static void BuildABsToWin64_LZMA()
{
//在assets下设定一个文件价用于存储ab资源
string path = Application.dataPath + "/AssetBundle";
//打包ab资源
BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
Debug.Log("AssetBundle资源打包完成");
} [MenuItem("BuildAB/BuildABToWin64/不压缩(体积大,加载快)")]
private static void BuildABsToWin64_UnComper()
{
//在assets下设定一个文件价用于存储ab资源
string path = Application.dataPath + "/AssetBundle";
//打包ab资源
BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);
Debug.Log("AssetBundle资源打包完成");
} [MenuItem("BuildAB/BuildABToWin64/LZ4(体积中,加载中)")]
private static void BuildABsToWin64_LZ4()
{
//在assets下设定一个文件价用于存储ab资源
string path = Application.dataPath + "/AssetBundle";
//打包ab资源
BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows64);
Debug.Log("AssetBundle资源打包完成");
} }