wechat-miniprogram / minigame-unity-webgl-transform

Wechat Mini Game Unity engine adapter documents.
https://wechat-miniprogram.github.io/minigame-unity-webgl-transform/
MIT License
2.98k stars 455 forks source link

真机使用Addressable加载资源报错,DevTool中正常 #649

Closed wood9366 closed 2 weeks ago

wood9366 commented 10 months ago

开发系统环境:macOS Sonoma Version 14.0 Unity版本:2021.2.5f1c303 微信小游戏转化插件版本:202312181916 DevTools版本:Stable 1.06.2310080 CDN:使用微信云托管的对象存储 测试手机:iphone SE2 手机微信版本:8.0.44

问题: DevTool中使用真机预览,使用Addressable加载资源报错

RemoteProviderException: TextDataProvider: unable to load from url: https://{CDN_PATH}/StreamingAssets/aa/settings.json

在DevTool中直接测试时没有问题

wood9366 commented 10 months ago

测试Unity工程,https://github.com/wood9366/test_wx_addressable

wood9366 commented 10 months ago

问题定位到只要用UnityWebRequest获取文件就会报连接错误,CDN用的是云托管的对象存储,应该不存在域名的限制问题。希望能帮忙解答。

var url = "https://7072-prod-6gvzhx3yebf7bd8b-1323067300.tcb.qcloud.la/test_wx_addressable/StreamingAssets/aa/settings.json";
UnityWebRequest req = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET, new DownloadHandlerBuffer(), null);

var h = req.SendWebRequest();

yield return h;

if (req.result == UnityWebRequest.Result.Success)
    Debug.Log($"download file succeess, content: {req.downloadHandler.text}");
else
    Debug.LogError($"download file fail, result: {req.result}, url: {url}");