Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unity使用 WXAssetBundle.GetAssetBundle(url)下载资源成功,但是assetbundle为空,用UnityWebRequestAssetBundle.GetAssetBundle又可以正常加载 #907

Open
wumiao1990 opened this issue Nov 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@wumiao1990
Copy link

描述Bug

UnityEngine.Networking.UnityWebRequest bundleReq = WeChatWASM.WXAssetBundle.GetAssetBundle(urlPath); // UnityWebRequestAssetBundle => WXAssetBundle
await bundleReq.SendWebRequest();
if (bundleReq.result == UnityEngine.Networking.UnityWebRequest.Result.Success)
{
UnityEngine.AssetBundle bundle = null;
try
{
var downloadHandler = bundleReq.downloadHandler;
bundle = (downloadHandler as DownloadHandlerWXAssetBundle)?.assetBundle; // DownloadHandlerAssetBundle => DownloadHandlerWXAssetBundle
Debug.LogError($"WXAssetBundle.GetAssetBundle Path:{urlPath} bundle:{bundle}");
}
catch (Exception e)
{
Logging.Error($"{GetType()} bundle is Null path:{urlPath} errorMsg:{e}");
}
if (bundle != null)
{
m_AssetBundle = bundle;
}
IsDone = true;
}
else
{
Logging.Error($"{GetType()} ERROR bundleReq.error path:{urlPath}");
}
bundleReq.Dispose();

运行环境

Unity2022.3.22
@wumiao1990 wumiao1990 added the bug Something isn't working label Nov 22, 2024
@wumiao1990 wumiao1990 changed the title unity使用 WXAssetBundle.GetAssetBundle(url)下载资源成功,但是assetbundle为空 unity使用 WXAssetBundle.GetAssetBundle(url)下载资源成功,但是assetbundle为空,用UnityWebRequestAssetBundle.GetAssetBundle又可以正常加载 Nov 22, 2024
@Kingrd97
Copy link

为null一般是网络错误,检查小游戏是否有相关日志。建议补上网络的判断 bundleReq.isHttpError || bundleReq.isNetworkError
还不行可联系小助手 https://work.weixin.qq.com/kfid/kfcca4feec277f91616

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants