
01.生成AB包
02.使用資源檔案
//加載AB包
AssetBundle asset= AssetBundle.LoadFromFile(Application.streamingAssetsPath+ "/model");
//加載資源
Instantiate(asset.LoadAsset<GameObject>("Cube"));
public Image image;
IEnumerator Load(string abName,string iconName)
{
AssetBundleCreateRequest request=AssetBundle.LoadFromFileAsync(Application.streamingAssetsPath + "/" + abName);
yield return request;
AssetBundleRequest sprite=request.assetBundle.LoadAssetAsync<Sprite>(iconName);
yield return sprite;
image.sprite = sprite.asset as Sprite;
}
03.資源依賴
AssetBundle asset= AssetBundle.LoadFromFile(Application.streamingAssetsPath+ "/model");
AssetBundle assetMain=AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/PC");
AssetBundleManifest abMainfest=assetMain.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
string[] str=abMainfest.GetAllDependencies("model");
for (int i = 0; i < str.Length; i++)
{
AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + str[i]);
}