![](/img/trans.png)
[英]Can't be loaded because another AssetBundle with the same files is already loaded
[英]can't be loaded because another AssetBundle with the same files is already loaded. error while loading different bundles
我試過從 URL 加載資產包。 當我只加載單個資產包時,它運行良好。 但是,如果我嘗試加載多個資產包,Unity 會給出此錯誤: The AssetBundle 'https://example.com/uc?export=download&id=1234567' can't be loaded because another AssetBundle with the same files is already loaded.
示例代碼如下
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using TMPro;
public class sahnecagir : MonoBehaviour
{
public TextMeshProUGUI Log;
// Start is called before the first frame update
void Start()
{
StartCoroutine(LoadBundleFromUrl("https://example.com/uc?export=download&id=123456", 2, 0, (uint)Crc.Gifts));
}
IEnumerator LoadBundleFromUrl(string url, int tip, uint version, uint crc)
{
using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(url, version, crc))
{
uwr.SendWebRequest();
while (!uwr.isDone)
{
if(tip == 1) Log.text = "Rooms loading " + (uwr.downloadProgress * 100).ToString("0") + "%";
else if(tip == 2) Log.text = "Gifts loading " + (uwr.downloadProgress * 100).ToString("0") + "%";
yield return null;
}
if (uwr.isNetworkError || uwr.isHttpError)
{
Debug.Log(uwr.error);
}
else
{
if (tip == 1)
{
MainConfig.Instance.RoomBgBundle = DownloadHandlerAssetBundle.GetContent(uwr);
}
else if (tip == 2)
{
MainConfig.Instance.GiftBundle = DownloadHandlerAssetBundle.GetContent(uwr);
}
}
if (uwr.isDone && tip == 1)
{
Log.text = "Rooms loading 100%";
StartCoroutine(LoadBundleFromUrl("https://example.com/uc?export=download&id=1234567", 2, 0, 0));
}
else
{
Log.text = "Gifts loading 100%";
}
yield return null;
}
}
}
就我而言,我一直在嘗試修改包含不同文件的包,但 Unity 拒絕加載這兩個不同的文件,即使它們具有不同的名稱、不同的結構、內部的不同文件,什么也沒有。
在 Notepad++ 中打開捆綁包會彈出我認為是 CAB-a317cdbf067bab183d6dd12d870c1407 的“容器名稱”作為示例。 這就是 Unity 似乎正在檢查以確定捆綁包是否“相同”的內容。
一個簡單的查找並替換為不同的名稱和繁榮。 捆綁包現在加載。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.