1.设置资源的AssetBundle名(有材质的可以给材质也设置,这里材质的AssetBundle名为share)
2.写个工具类来完成AssetBundle打包
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
public class AssetBundleAB
{
[MenuItem("Assets/AssetBundle/BuildAB")]
static void BuildAB()
{
Debug.Log("打包完成");
string path = "Assets/AssetsBundles";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);//三个参数分别表示打包路径,打包压缩格式,打包平台
AssetDatabase.Refresh();//刷新
}
}
打包后