首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法解压缩AssetBundle 'Memory‘的数据。(Webgl)

无法解压缩AssetBundle 'Memory‘的数据。(Webgl)
EN

Stack Overflow用户
提问于 2019-10-03 14:50:47
回答 1查看 4.5K关注 0票数 1

我在为webgl做一个游戏。但是,当我在链接上上传资源包,然后将其加载到游戏中时,它显示错误。

错误:无法解压缩AssetBundle 'Memory‘的数据。UnityEngine.WWW:get_assetBundle()

NullReferenceException:对象引用未设置为对象DownloadScript+d__2.MoveNext ()的实例(位于Assets/DownloadScript.cs:27)

当我从我的系统(本地)加载资产时,它完美地加载了它。但是当我把它上传到一个实时链接上时,它并没有加载它。

这是我从服务器加载它的代码

“”“

代码语言:javascript
复制
public class DownloadScript : MonoBehaviour
{
public string url;

// Start is called before the first frame update
[System.Obsolete]
void Start()
{
    StartCoroutine(DownloadModel());
}

[System.Obsolete]
IEnumerator DownloadModel()
{
    WWW wwws = new WWW(url);
    yield return wwws;
    //UnityWebRequest www = UnityWebRequest.GetAssetBundle();
    //yield return www.SendWebRequest();


    AssetBundle assetBundle = wwws.assetBundle;
    Instantiate(assetBundle.LoadAsset("cube"));

}

“”“

从本地系统加载的代码:

“”“

代码语言:javascript
复制
AssetBundle myLoadedAssetbundle;
public string path;
public string bundleAsset;
void Start()
{
    LoadAssetBundle(path);
    //InstantiateObjectFromBundle(bundleAsset);
    StartCoroutine(DownloadAndCache(path));
}

void LoadAssetBundle(string bundleUrl)
{
    myLoadedAssetbundle = AssetBundle.LoadFromFile(bundleUrl);
    //myLoadedAssetbundle = AssetBundle.

    Debug.Log(myLoadedAssetbundle == null ? "Failed to load AssetBundle" : "AssetBundle Succesfully Loaded");
}

void InstantiateObjectFromBundle(string assetName)
{
    var prefab = myLoadedAssetbundle.LoadAsset(assetName);
    Instantiate(prefab);
}

“”“

EN

回答 1

Stack Overflow用户

发布于 2019-10-03 16:05:33

您确定您在构建资产包时也考虑到了正确的平台吗?为桌面构建的Assetbundle不一定适用于webgl。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58213726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档