tuyoogame / YooAsset

unity3d resources management system
https://www.yooasset.com/
Apache License 2.0
2.37k stars 466 forks source link

微信小游戏平台使用Extension Sample中下载器,OnDownloadProgressCallback进度异常 #341

Open centoliu opened 1 month ago

centoliu commented 1 month ago

OnDownloadProgressCallback第四个参数恒为0 WXFSDownloadFileOperation DownloadedBytes[0] DownloadProgress[0] 环境:Unity2021,YooAsset2.2.2

gmhevinci commented 1 month ago

WechatFileSystem.cs类里,请确认一下下面方法实现是否有效,如果没有正确返回结果,会导致每次都会去尝试下载本地已经缓存的文件。

    public virtual void OnCreate(string packageName, string rootDirectory)
    {
        PackageName = packageName;

        _wxFileSystemMgr = WX.GetFileSystemManager();
        _wxFileCacheRoot = WX.env.USER_DATA_PATH; //注意:如果有子目录,请修改此处!
    }

    public virtual bool Exists(PackageBundle bundle)
    {
        string filePath = GetWXFileLoadPath(bundle);
        string result = _wxFileSystemMgr.AccessSync(filePath);
        return result.Equals("access:ok");
    }
gmhevinci commented 1 month ago

该问题请勿关闭~

centoliu commented 1 month ago
  1. Exists没有命中,打印_wxFileCacheRoot = http://usr/ver112/StreamingAssets/xxx.bundle
  2. 非首次下载微信转换插件日志有CacheXMLHttpRequest_onload命中本地缓存,实际上没有重新下载 image
gmhevinci commented 1 month ago

请确认一下非首次下载是否被检测成需要下载

    public virtual bool NeedDownload(PackageBundle bundle)
    {
        if (Belong(bundle) == false)
            return false;

        return Exists(bundle) == false;
    }
gmhevinci commented 1 month ago

这是微信文件系统的下载器,如果以上都没问题,那么可以在这里打印下载进度值。可能该问题出自于微信小游戏插件。 image

centoliu commented 1 month ago

那可能是微信插件问题了,这个_webRequest.downloadedBytes打印一直是0,首次下载和非首次都是0

gmhevinci commented 1 month ago

可以反馈给微信小游戏插件。该问题暂不用关闭