C# 未能解压缩资产绑定的数据';内存';。(Webgl)
我正在为webgl制作一个游戏。但是当我在链接上上传资产绑定,然后在游戏中加载时,它显示错误 错误: 未能解压缩资产绑定“内存”的数据。 UnityEngine.WWW:get_assetBundle() NullReferenceException:对象引用未设置为对象的实例 DownloadScript+d__2.MoveNext()(位于Assets/DownloadScript.cs:27) 当我从系统(本地)加载资源时,它会完美地加载它。但当我把它上传到一个实时链接上时,它并没有加载它 这是我从服务器加载它的代码 ''' ''' 要从本地系统加载的代码: '''C# 未能解压缩资产绑定的数据';内存';。(Webgl),c#,visual-studio,unity3d,unity-webgl,assetbundle,C#,Visual Studio,Unity3d,Unity Webgl,Assetbundle,我正在为webgl制作一个游戏。但是当我在链接上上传资产绑定,然后在游戏中加载时,它显示错误 错误: 未能解压缩资产绑定“内存”的数据。 UnityEngine.WWW:get_assetBundle() NullReferenceException:对象引用未设置为对象的实例 DownloadScript+d__2.MoveNext()(位于Assets/DownloadScript.cs:27) 当我从系统(本地)加载资源时,它会完美地加载它。但当我把它上传到一个实时链接上时,它并没有加载它
''您确定您也在使用正确的平台构建资产组合吗?为桌面构建的资产绑定不一定适用于webgl
实例化(assetBundle.LoadAsset(“多维数据集”)代码>但是您没有对实例化的对象执行任何操作是的,但是对象必须是实例化的。您能够修复它吗?生成资产绑定的方式与webgl不同吗?现在游戏选择了webgl平台。当我在unity中从local加载它时,它工作得很好。但在unity中,我尝试从服务器加载它时,它不起作用>“生成资产绑定的方式与webgl不同吗?”是的,非常不同。当您创建资产绑定时,您提供了一个平台,请确保您正在使用该平台。您能对此做一点简要介绍吗?我不明白
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"));
}
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);
}