From f5c72e913f1bb999315f8f1e4611598228be37bd Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 28 Jun 2023 17:46:32 +0800 Subject: [PATCH] update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增方法YooAssets.SetCacheSystemDisableCacheOnWebGL() --- .../AssetSystem/Loader/AssetBundleWebLoader.cs | 17 +++++++++++++---- .../YooAsset/Runtime/CacheSystem/CacheSystem.cs | 5 +++++ Assets/YooAsset/Runtime/YooAssets.cs | 8 ++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs index 2f96992..d775d18 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs @@ -168,10 +168,19 @@ namespace YooAsset // 5. 从WEB网站获取AssetBundle文件 if (_steps == ESteps.LoadWebFile) { - var hash = Hash128.Parse(MainBundleInfo.Bundle.FileHash); - _webRequest = UnityWebRequestAssetBundle.GetAssetBundle(FileLoadPath, hash); - _webRequest.SendWebRequest(); - _steps = ESteps.CheckLoadWebFile; + if (CacheSystem.DisableUnityCacheOnWebGL) + { + _webRequest = UnityWebRequestAssetBundle.GetAssetBundle(FileLoadPath); + _webRequest.SendWebRequest(); + _steps = ESteps.CheckLoadWebFile; + } + else + { + var hash = Hash128.Parse(MainBundleInfo.Bundle.FileHash); + _webRequest = UnityWebRequestAssetBundle.GetAssetBundle(FileLoadPath, hash); + _webRequest.SendWebRequest(); + _steps = ESteps.CheckLoadWebFile; + } } // 6. 检测AssetBundle加载结果 diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs index 65c3094..6f3b87e 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs @@ -10,6 +10,11 @@ namespace YooAsset { private readonly static Dictionary _cachedDic = new Dictionary(1000); + /// + /// 禁用Unity缓存系统在WebGL平台 + /// + public static bool DisableUnityCacheOnWebGL = false; + /// /// 初始化时的验证级别 /// diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 2875071..fa83938 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -258,6 +258,14 @@ namespace YooAsset PersistentTools.OverwriteSandboxPath(sandboxPath); } + + /// + /// 设置缓存系统参数,禁用缓存在WebGL平台 + /// + public static void SetCacheSystemDisableCacheOnWebGL() + { + CacheSystem.DisableUnityCacheOnWebGL = true; + } #endregion #region 沙盒相关