From fbec06fa815cb4cebbc9df4de52aff9525f8adbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Mon, 19 Aug 2024 12:29:54 +0800 Subject: [PATCH] update extension sample --- .../ByteGameFileSystem/ByteGameFileSystem.cs | 5 ++-- .../WechatFileSystem/WechatFileSystem.cs | 24 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Assets/YooAsset/Samples~/Extension Sample/Runtime/ByteGameFileSystem/ByteGameFileSystem.cs b/Assets/YooAsset/Samples~/Extension Sample/Runtime/ByteGameFileSystem/ByteGameFileSystem.cs index db00534..3454741 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Runtime/ByteGameFileSystem/ByteGameFileSystem.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Runtime/ByteGameFileSystem/ByteGameFileSystem.cs @@ -177,7 +177,8 @@ internal class ByteGameFileSystem : IFileSystem } public virtual bool Exists(PackageBundle bundle) { - return _fileSystemManager.AccessSync(bundle.FileName); + string filePath = GetCacheFileLoadPath(bundle); + return _fileSystemManager.AccessSync(filePath); } public virtual bool NeedDownload(PackageBundle bundle) { @@ -205,7 +206,7 @@ internal class ByteGameFileSystem : IFileSystem } #region 内部方法 - private string GetFileLoadPath(PackageBundle bundle) + private string GetCacheFileLoadPath(PackageBundle bundle) { if (_cacheFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) { diff --git a/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem/WechatFileSystem.cs b/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem/WechatFileSystem.cs index 9982cb7..894a3bd 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem/WechatFileSystem.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem/WechatFileSystem.cs @@ -51,9 +51,9 @@ internal class WechatFileSystem : IFileSystem } } - private readonly Dictionary _wxFilePaths = new Dictionary(10000); - private WXFileSystemManager _wxFileSystemMgr; - private string _wxFileCacheRoot = string.Empty; + private readonly Dictionary _cacheFilePaths = new Dictionary(10000); + private WXFileSystemManager _fileSystemManager; + private string _fileCacheRoot = string.Empty; /// /// 包裹名称 @@ -67,7 +67,7 @@ internal class WechatFileSystem : IFileSystem { get { - return _wxFileCacheRoot; + return _fileCacheRoot; } } @@ -166,8 +166,8 @@ internal class WechatFileSystem : IFileSystem RemoteServices = new WebRemoteServices(webRoot); } - _wxFileSystemMgr = WX.GetFileSystemManager(); - _wxFileCacheRoot = WX.env.USER_DATA_PATH; //注意:如果有子目录,请修改此处! + _fileSystemManager = WX.GetFileSystemManager(); + _fileCacheRoot = WX.env.USER_DATA_PATH; //注意:如果有子目录,请修改此处! } public virtual void OnUpdate() { @@ -179,8 +179,8 @@ internal class WechatFileSystem : IFileSystem } public virtual bool Exists(PackageBundle bundle) { - string filePath = GetWXFileLoadPath(bundle); - string result = _wxFileSystemMgr.AccessSync(filePath); + string filePath = GetCacheFileLoadPath(bundle); + string result = _fileSystemManager.AccessSync(filePath); return result.Equals("access:ok"); } public virtual bool NeedDownload(PackageBundle bundle) @@ -209,12 +209,12 @@ internal class WechatFileSystem : IFileSystem } #region 内部方法 - private string GetWXFileLoadPath(PackageBundle bundle) + private string GetCacheFileLoadPath(PackageBundle bundle) { - if (_wxFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) + if (_cacheFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) { - filePath = PathUtility.Combine(_wxFileCacheRoot, bundle.FileName); - _wxFilePaths.Add(bundle.BundleGUID, filePath); + filePath = PathUtility.Combine(_fileCacheRoot, bundle.FileName); + _cacheFilePaths.Add(bundle.BundleGUID, filePath); } return filePath; }