mirror of https://github.com/tuyoogame/YooAsset
parent
4c619778c3
commit
a93704c60b
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Net;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
|
@ -29,6 +30,12 @@ namespace YooAsset
|
|||
// 解析附加参数
|
||||
_getAssetBundle = (bool)args[0];
|
||||
|
||||
#if UNITY_WECHAT_GAME && !UNITY_EDITOR
|
||||
uint crc = bundleInfo.Bundle.UnityCRC;
|
||||
_webRequest = WeChatWASM.WXAssetBundle.GetAssetBundle(requestURL, crc);
|
||||
_webRequest.disposeDownloadHandlerOnDispose = false;
|
||||
#else
|
||||
|
||||
// 创建下载器
|
||||
_webRequest = DownloadHelper.NewRequest(requestURL);
|
||||
if (CacheHelper.DisableUnityCacheOnWebGL)
|
||||
|
@ -47,6 +54,8 @@ namespace YooAsset
|
|||
#endif
|
||||
_webRequest.downloadHandler = _downloadhandler;
|
||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||
#endif
|
||||
|
||||
_webRequest.SendWebRequest();
|
||||
Status = ERequestStatus.InProgress;
|
||||
}
|
||||
|
@ -92,7 +101,11 @@ namespace YooAsset
|
|||
{
|
||||
if (_getAssetBundle)
|
||||
{
|
||||
#if UNITY_WECHAT_GAME && !UNITY_EDITOR
|
||||
_cacheAssetBundle = (_webRequest.downloadHandler as WeChatWASM.DownloadHandlerWXAssetBundle).assetBundle;
|
||||
#else
|
||||
_cacheAssetBundle = _downloadhandler.assetBundle;
|
||||
#endif
|
||||
if (_cacheAssetBundle == null)
|
||||
{
|
||||
RequestNetError = "assetBundle is null";
|
||||
|
|
|
@ -156,7 +156,11 @@ namespace YooAsset
|
|||
|
||||
if (CacheBundle != null)
|
||||
{
|
||||
#if UNITY_WECHAT_GAME && !UNITY_EDITOR
|
||||
WeChatWASM.AssetBundleExtensions.WXUnload(CacheBundle, true);
|
||||
#else
|
||||
CacheBundle.Unload(true);
|
||||
#endif
|
||||
CacheBundle = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,13 +65,15 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
// 查询相关
|
||||
#if UNITY_WECHAT_GAME
|
||||
// 未命中缓存的情况,微信小程序会抛出报错,日志数量多了会卡。
|
||||
#if UNITY_WECHAT_GAME && !UNITY_EDITOR
|
||||
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;
|
||||
// 如果微信小游戏设置的CDN后面还有子目录,这里也要相应添加
|
||||
string filePath = System.IO.Path.Combine(WeChatWASM.WX.env.USER_DATA_PATH, "__GAME_FILE_CACHE", packageBundle.FileName);
|
||||
string result = _wxFileSystemMgr.AccessSync(filePath);
|
||||
return result.Equals("access:ok");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue