feat : wechat game cache query

pull/229/head
hevinci 2024-01-03 16:24:02 +08:00
parent 1fb78185ff
commit 95328fe1a6
1 changed files with 29 additions and 0 deletions

View File

@ -65,6 +65,23 @@ namespace YooAsset
} }
// 查询相关 // 查询相关
#if UNITY_WX_GAME
private WeChatWASM.WXFileSystemManager _wxFileSystemMgr;
private bool IsCachedPackageBundle(PackageBundle packageBundle)
{
if (_wxFileSystemMgr == null)
_wxFileSystemMgr = WeChatWASM.WX.GetFileSystemManager();
string filePath = WeChatWASM.WX.env.USER_DATA_PATH + packageBundle.FileName;
string result = _wxFileSystemMgr.AccessSync(filePath);
return result.Equals("access:ok");
}
#else
private bool IsCachedPackageBundle(PackageBundle packageBundle)
{
return false;
}
#endif
private bool IsBuildinPackageBundle(PackageBundle packageBundle) private bool IsBuildinPackageBundle(PackageBundle packageBundle)
{ {
return _buildinQueryServices.Query(PackageName, packageBundle.FileName, packageBundle.FileCRC); return _buildinQueryServices.Query(PackageName, packageBundle.FileName, packageBundle.FileCRC);
@ -116,6 +133,10 @@ namespace YooAsset
List<PackageBundle> downloadList = new List<PackageBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in manifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
// 忽略APP资源 // 忽略APP资源
if (IsBuildinPackageBundle(packageBundle)) if (IsBuildinPackageBundle(packageBundle))
continue; continue;
@ -137,6 +158,10 @@ namespace YooAsset
List<PackageBundle> downloadList = new List<PackageBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in manifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
// 忽略APP资源 // 忽略APP资源
if (IsBuildinPackageBundle(packageBundle)) if (IsBuildinPackageBundle(packageBundle))
continue; continue;
@ -194,6 +219,10 @@ namespace YooAsset
List<PackageBundle> downloadList = new List<PackageBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in checkList) foreach (var packageBundle in checkList)
{ {
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
// 忽略APP资源 // 忽略APP资源
if (IsBuildinPackageBundle(packageBundle)) if (IsBuildinPackageBundle(packageBundle))
continue; continue;