簡體   English   中英

無法加載,因為已經加載了另一個具有相同文件的 AssetBundle。 加載不同包時出錯

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM