mirror of https://github.com/tuyoogame/YooAsset
update extension sample
parent
d34d1117a0
commit
ae454b72dc
|
@ -21,6 +21,36 @@ public static class WechatFileSystemCreater
|
|||
/// </summary>
|
||||
internal class WechatFileSystem : IFileSystem
|
||||
{
|
||||
private class WebRemoteServices : IRemoteServices
|
||||
{
|
||||
private readonly string _webPackageRoot;
|
||||
protected readonly Dictionary<string, string> _mapping = new Dictionary<string, string>(10000);
|
||||
|
||||
public WebRemoteServices(string buildinPackRoot)
|
||||
{
|
||||
_webPackageRoot = buildinPackRoot;
|
||||
}
|
||||
string IRemoteServices.GetRemoteMainURL(string fileName)
|
||||
{
|
||||
return GetFileLoadURL(fileName);
|
||||
}
|
||||
string IRemoteServices.GetRemoteFallbackURL(string fileName)
|
||||
{
|
||||
return GetFileLoadURL(fileName);
|
||||
}
|
||||
|
||||
private string GetFileLoadURL(string fileName)
|
||||
{
|
||||
if (_mapping.TryGetValue(fileName, out string url) == false)
|
||||
{
|
||||
string filePath = PathUtility.Combine(_webPackageRoot, fileName);
|
||||
url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_mapping.Add(fileName, url);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, string> _wxFilePaths = new Dictionary<string, string>(10000);
|
||||
private WXFileSystemManager _wxFileSystemMgr;
|
||||
private string _wxFileCacheRoot = string.Empty;
|
||||
|
@ -129,6 +159,13 @@ internal class WechatFileSystem : IFileSystem
|
|||
{
|
||||
PackageName = packageName;
|
||||
|
||||
// 注意:CDN服务未启用的情况下,使用微信WEB服务器
|
||||
if (RemoteServices == null)
|
||||
{
|
||||
string webRoot = PathUtility.Combine(Application.streamingAssetsPath, YooAssetSettingsData.Setting.DefaultYooFolderName, packageName);
|
||||
RemoteServices = new WebRemoteServices(webRoot);
|
||||
}
|
||||
|
||||
_wxFileSystemMgr = WX.GetFileSystemManager();
|
||||
_wxFileCacheRoot = WX.env.USER_DATA_PATH; //注意:如果有子目录,请修改此处!
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue