From af7aecbf0be9479a8347b2200c73d57644a2f631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= <33317070@qq.com> Date: Tue, 26 May 2026 19:18:29 +0800 Subject: [PATCH] change : remove legacy WebGame and WebRemote file systems --- .../Common/LoadWebAssetBundleOperation.cs | 129 --------- .../LoadWebAssetBundleOperation.cs.meta | 11 - .../Common/LoadWebAssetBundleOptions.cs | 76 ------ .../Common/LoadWebAssetBundleOptions.cs.meta | 11 - .../Services/WebGameBundleCache.meta | 8 - .../WebGameBundleCache/Operations.meta | 8 - .../Operations/Internal.meta | 8 - .../LoadWebGameAssetBundleOperation.cs | 121 --------- .../LoadWebGameAssetBundleOperation.cs.meta | 11 - .../Internal/LoadWebGameAssetBundleOptions.cs | 52 ---- .../LoadWebGameAssetBundleOptions.cs.meta | 11 - .../Operations/WGBCInitializeOperation.cs | 17 -- .../WGBCInitializeOperation.cs.meta | 11 - .../WGBCLoadAssetBundleOperation.cs | 100 ------- .../WGBCLoadAssetBundleOperation.cs.meta | 11 - .../Operations/WGBCLoadRawBundleOperation.cs | 85 ------ .../WGBCLoadRawBundleOperation.cs.meta | 11 - .../WebGameBundleCache/WebGameBundleCache.cs | 175 ------------ .../WebGameBundleCache.cs.meta | 11 - .../Services/WebRemoteBundleCache.meta | 8 - .../WebRemoteBundleCache/Operations.meta | 8 - .../Operations/WRBCInitializeOperation.cs | 27 -- .../WRBCInitializeOperation.cs.meta | 11 - .../WRBCLoadAssetBundleOperation.cs | 110 -------- .../WRBCLoadAssetBundleOperation.cs.meta | 11 - .../Operations/WRBCLoadRawBundleOperation.cs | 85 ------ .../WRBCLoadRawBundleOperation.cs.meta | 11 - .../WebRemoteBundleCache.cs | 170 ------------ .../WebRemoteBundleCache.cs.meta | 11 - .../Services/WebGameBundleHandle.meta | 8 - .../WebGameAssetBundleHandle.cs | 68 ----- .../WebGameAssetBundleHandle.cs.meta | 11 - .../Compatibility/CompatibleFileSystem.cs | 24 +- .../CompatibleResourcePackage.cs | 2 +- .../Services/WebGameRequest.meta | 8 - .../WebGameAssetBundleRequest.cs | 44 --- .../WebGameAssetBundleRequest.cs.meta | 11 - .../FileSystem/Interfaces/IWebGamePlatform.cs | 32 --- .../Interfaces/IWebGamePlatform.cs.meta | 11 - .../Services/WebGameFileSystem.meta | 8 - .../WebGameFileSystem/Operations.meta | 8 - .../Operations/WGFSInitializeOperation.cs | 96 ------- .../WGFSInitializeOperation.cs.meta | 11 - .../WGFSLoadPackageBundleOperation.cs | 79 ------ .../WGFSLoadPackageBundleOperation.cs.meta | 11 - .../WGFSLoadPackageManifestOperation.cs | 106 -------- .../WGFSLoadPackageManifestOperation.cs.meta | 11 - .../WGFSRequestPackageVersionOperation.cs | 71 ----- ...WGFSRequestPackageVersionOperation.cs.meta | 11 - .../WebGameFileSystem/WebGameFileSystem.cs | 253 ------------------ .../WebGameFileSystem.cs.meta | 11 - .../Services/WebRemoteFileSystem.meta | 8 - .../WebRemoteFileSystem/Operations.meta | 8 - .../Operations/WRFSInitializeOperation.cs | 84 ------ .../WRFSInitializeOperation.cs.meta | 11 - .../WRFSLoadPackageBundleOperation.cs | 80 ------ .../WRFSLoadPackageBundleOperation.cs.meta | 11 - .../WRFSLoadPackageManifestOperation.cs | 108 -------- .../WRFSLoadPackageManifestOperation.cs.meta | 11 - .../WRFSRequestPackageVersionOperation.cs | 73 ----- ...WRFSRequestPackageVersionOperation.cs.meta | 11 - .../WebRemoteFileSystem.cs | 249 ----------------- .../WebRemoteFileSystem.cs.meta | 11 - .../AlipayFileSystem/AlipayFileSystem.cs | 31 +-- .../AlipayFileSystem/AlipayPlatform.cs | 8 +- .../KuaiShouFileSystem/KuaiShouFileSystem.cs | 31 +-- .../KuaiShouFileSystem/KuaiShouPlatform.cs | 8 +- .../Runtime/KuaiShouFileSystem/README.md | 5 +- .../Runtime/OppoFileSystem/OppoFileSystem.cs | 31 +-- .../Runtime/OppoFileSystem/OppoPlatform.cs | 8 +- .../Runtime/OppoFileSystem/README.md | 5 +- .../TaptapFileSystem/TaptapFileSystem.cs | 30 +-- .../TaptapFileSystem/TaptapPlatform.cs | 8 +- .../TiktokFileSystem/TiktokFileSystem.cs | 31 +-- .../TiktokFileSystem/TiktokPlatform.cs | 8 +- .../Runtime/VivoFileSystem/README.md | 5 +- .../Runtime/VivoFileSystem/VivoFileSystem.cs | 31 +-- .../Runtime/VivoFileSystem/VivoPlatform.cs | 8 +- .../WechatFileSystem/WechatFileSystem.cs | 43 ++- .../WechatFileSystem/WechatPlatform.cs | 8 +- 80 files changed, 152 insertions(+), 3026 deletions(-) delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs delete mode 100644 Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs.meta delete mode 100644 Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle.meta delete mode 100644 Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs delete mode 100644 Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs.meta delete mode 100644 Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest.meta delete mode 100644 Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs delete mode 100644 Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs.meta delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs delete mode 100644 Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs.meta diff --git a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs deleted file mode 100644 index 0c81e86c..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs +++ /dev/null @@ -1,129 +0,0 @@ -using UnityEngine; - -namespace YooAsset -{ - /// - /// 从网络加载未加密 AssetBundle 操作 - /// - internal sealed class LoadWebNormalAssetBundleOperation : BCLoadBundleOperation - { - private enum ESteps - { - None, - BundleRequest, - CheckRequest, - TryAgain, - Done, - } - - private readonly LoadWebAssetBundleOptions _options; - private readonly DownloadRetryController _downloadRetryController; - private IDownloadAssetBundleRequest _downloadAssetBundleRequest; - private ESteps _steps = ESteps.None; - - /// - /// 创建 AssetBundle 加载操作实例 - /// - /// 从网络加载 AssetBundle 的操作选项 - public LoadWebNormalAssetBundleOperation(LoadWebAssetBundleOptions options) - { - _options = options; - - // 注意:网络原因失败后,重新尝试直到成功 - _downloadRetryController = new DownloadRetryController(int.MaxValue, options.DownloadRetryPolicy); - } - protected override void InternalStart() - { - _steps = ESteps.BundleRequest; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.BundleRequest) - { - string url = _options.DownloadUrlPolicy.SelectUrl(_options.CandidateUrls); - var args = new DownloadAssetBundleRequestArgs( - url: url, - timeout: 0, - watchdogTimeout: _options.WatchdogTimeout, - disableUnityWebCache: _options.DisableUnityWebCache, - fileHash: _options.Bundle.FileHash, - unityCrc: _options.Bundle.UnityCrc, - platformStrategy : null); - _downloadAssetBundleRequest = _options.DownloadBackend.CreateAssetBundleRequest(args); - _downloadAssetBundleRequest.SendRequest(); - _steps = ESteps.CheckRequest; - } - - if (_steps == ESteps.CheckRequest) - { - Progress = _downloadAssetBundleRequest.DownloadProgress; - if (_downloadAssetBundleRequest.IsDone == false) - return; - - if (_downloadAssetBundleRequest.Status == EDownloadRequestStatus.Succeeded) - { - _options.DownloadUrlPolicy.OnRequestSucceeded(_downloadAssetBundleRequest.Url); - var assetBundle = _downloadAssetBundleRequest.Result; - if (assetBundle == null) - { - _steps = ESteps.Done; - SetError($"Downloaded asset bundle is null. URL: {_downloadAssetBundleRequest.Url}"); - } - else - { - _steps = ESteps.Done; - SetResult(); - BundleHandle = new AssetBundleHandle(_options.Bundle, assetBundle, null); - } - } - else - { - string url = _downloadAssetBundleRequest.Url; - long httpCode = _downloadAssetBundleRequest.HttpCode; - string httpError = _downloadAssetBundleRequest.HttpError; - _options.DownloadUrlPolicy.OnRequestFailed(url, httpCode, httpError); - - if (IsWaitForCompletion == false && _downloadRetryController.CanRetryRequest(url, httpCode, httpError)) - { - _downloadRetryController.StartRetryDelay(); - _steps = ESteps.TryAgain; - } - else - { - _steps = ESteps.Done; - SetError(_downloadAssetBundleRequest.Error); - YooLogger.LogError(Error); - } - } - } - - if (_steps == ESteps.TryAgain) - { - // 注意:失败后释放网络请求 - if (_downloadAssetBundleRequest != null) - { - _downloadAssetBundleRequest.Dispose(); - _downloadAssetBundleRequest = null; - } - - if (_downloadRetryController.TickRetryDelay()) - { - Progress = 0f; - _steps = ESteps.BundleRequest; - } - } - } - protected override void InternalDispose() - { - if (_downloadAssetBundleRequest != null) - { - _downloadAssetBundleRequest.Dispose(); - _downloadAssetBundleRequest = null; - } - } - } - -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs.meta deleted file mode 100644 index 179d0179..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f0fd9af541471154d9fc968abd450d31 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs b/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs deleted file mode 100644 index 26d44ee1..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Collections.Generic; - -namespace YooAsset -{ - /// - /// 加载 AssetBundle 的操作选项 - /// - internal readonly struct LoadWebAssetBundleOptions - { - /// - /// 文件缓存名称 - /// - public string CacheName { get; } - - /// - /// 资源包描述 - /// - public PackageBundle Bundle { get; } - - /// - /// 候选下载地址列表 - /// - public IReadOnlyList CandidateUrls { get; } - - /// - /// AssetBundle 解密器 - /// - public IBundleDecryptor AssetBundleDecryptor { get; } - - /// - /// 下载后台接口 - /// - public IDownloadBackend DownloadBackend { get; } - - /// - /// 下载数据校验级别 - /// - public EFileVerifyLevel DownloadVerifyLevel { get; } - - /// - /// 看门狗超时时间 - /// - public int WatchdogTimeout { get; } - - /// - /// 禁用 Unity 内置网络缓存 - /// - public bool DisableUnityWebCache { get; } - - /// - /// 下载重试判定策略 - /// - public IDownloadRetryPolicy DownloadRetryPolicy { get; } - - /// - /// URL 选择策略 - /// - public IDownloadUrlPolicy DownloadUrlPolicy { get; } - - public LoadWebAssetBundleOptions(string cacheName, PackageBundle bundle, IReadOnlyList candidateUrls, - IBundleDecryptor assetBundleDecryptor, IDownloadBackend downloadBackend, EFileVerifyLevel downloadVerifyLevel, - int watchdogTimeout, bool disableUnityWebCache, IDownloadRetryPolicy downloadRetryPolicy, IDownloadUrlPolicy downloadUrlPolicy) - { - CacheName = cacheName; - Bundle = bundle; - CandidateUrls = candidateUrls; - AssetBundleDecryptor = assetBundleDecryptor; - DownloadBackend = downloadBackend; - DownloadVerifyLevel = downloadVerifyLevel; - WatchdogTimeout = watchdogTimeout; - DisableUnityWebCache = disableUnityWebCache; - DownloadRetryPolicy = downloadRetryPolicy; - DownloadUrlPolicy = downloadUrlPolicy; - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs.meta deleted file mode 100644 index 615d1299..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Operations/Common/LoadWebAssetBundleOptions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4c79e03ac8bcbef4aa0e2eede5bf63fb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache.meta deleted file mode 100644 index 1569367f..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f6cbd76495075b54993179318fdda8dc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations.meta deleted file mode 100644 index 86999699..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ead67fdda05e99747b03f49accc1526a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal.meta deleted file mode 100644 index e95a6876..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9c86f68bc316ce54ca9396e6e6c2dd8f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs deleted file mode 100644 index c7d15448..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs +++ /dev/null @@ -1,121 +0,0 @@ -using UnityEngine; - -namespace YooAsset -{ - /// - /// 从 WebGL 游戏平台加载非加密 AssetBundle 操作 - /// - internal sealed class LoadWebGameAssetBundleOperation : BCLoadBundleOperation - { - private enum ESteps - { - None, - BundleRequest, - CheckRequest, - TryAgain, - Done, - } - - private readonly LoadWebGameAssetBundleOptions _options; - private readonly DownloadRetryController _downloadRetryController; - private IDownloadAssetBundleRequest _downloadAssetBundleRequest; - private ESteps _steps = ESteps.None; - - internal LoadWebGameAssetBundleOperation(LoadWebGameAssetBundleOptions options) - { - _options = options; - - // 注意:网络原因失败后,重新尝试直到成功 - _downloadRetryController = new DownloadRetryController(int.MaxValue, options.DownloadRetryPolicy); - } - protected override void InternalStart() - { - _steps = ESteps.BundleRequest; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.BundleRequest) - { - string url = _options.DownloadUrlPolicy.SelectUrl(_options.CandidateUrls); - var args = new DownloadRequestArgs( - url: url, - timeout: 0, - watchdogTimeout: _options.WatchdogTimeout); - _downloadAssetBundleRequest = new WebGameAssetBundleRequest(args, _options.GamePlatform); - _downloadAssetBundleRequest.SendRequest(); - _steps = ESteps.CheckRequest; - } - - if (_steps == ESteps.CheckRequest) - { - //TODO 部分小游戏平台的 downloadProgress 始终返回 0,导致进度条无法正确显示。 - Progress = _downloadAssetBundleRequest.DownloadProgress; - if (_downloadAssetBundleRequest.IsDone == false) - return; - - if (_downloadAssetBundleRequest.Status == EDownloadRequestStatus.Succeeded) - { - _options.DownloadUrlPolicy.OnRequestSucceeded(_downloadAssetBundleRequest.Url); - var assetBundle = _downloadAssetBundleRequest.Result; - if (assetBundle == null) - { - _steps = ESteps.Done; - SetError($"Downloaded asset bundle is null. URL: {_downloadAssetBundleRequest.Url}"); - } - else - { - _steps = ESteps.Done; - SetResult(); - BundleHandle = new WebGameAssetBundleHandle(_options.Bundle, assetBundle, _options.GamePlatform); - } - } - else - { - string url = _downloadAssetBundleRequest.Url; - long httpCode = _downloadAssetBundleRequest.HttpCode; - string httpError = _downloadAssetBundleRequest.HttpError; - _options.DownloadUrlPolicy.OnRequestFailed(url, httpCode, httpError); - - if (IsWaitForCompletion == false && _downloadRetryController.CanRetryRequest(url, httpCode, httpError)) - { - _downloadRetryController.StartRetryDelay(); - _steps = ESteps.TryAgain; - } - else - { - _steps = ESteps.Done; - SetError(_downloadAssetBundleRequest.Error); - YooLogger.LogError(Error); - } - } - } - - if (_steps == ESteps.TryAgain) - { - // 注意:失败后释放网络请求 - if (_downloadAssetBundleRequest != null) - { - _downloadAssetBundleRequest.Dispose(); - _downloadAssetBundleRequest = null; - } - - if (_downloadRetryController.TickRetryDelay()) - { - Progress = 0f; - _steps = ESteps.BundleRequest; - } - } - } - protected override void InternalDispose() - { - if (_downloadAssetBundleRequest != null) - { - _downloadAssetBundleRequest.Dispose(); - _downloadAssetBundleRequest = null; - } - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs.meta deleted file mode 100644 index 7faba4ba..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5ef65b981b91200439b05f29435e7c92 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs deleted file mode 100644 index a2a00b9d..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; - -namespace YooAsset -{ - /// - /// WebGL 游戏平台加载 AssetBundle 的操作选项 - /// - internal readonly struct LoadWebGameAssetBundleOptions - { - /// - /// 资源包描述 - /// - public PackageBundle Bundle { get; } - - /// - /// 候选下载地址列表 - /// - public IReadOnlyList CandidateUrls { get; } - - /// - /// 游戏平台接口 - /// - public IWebGamePlatform GamePlatform { get; } - - /// - /// 看门狗超时时间 - /// - public int WatchdogTimeout { get; } - - /// - /// 下载重试判定策略 - /// - public IDownloadRetryPolicy DownloadRetryPolicy { get; } - - /// - /// URL 选择策略 - /// - public IDownloadUrlPolicy DownloadUrlPolicy { get; } - - public LoadWebGameAssetBundleOptions(PackageBundle bundle, IReadOnlyList candidateUrls, - IWebGamePlatform gamePlatform, int watchdogTimeout, - IDownloadRetryPolicy downloadRetryPolicy, IDownloadUrlPolicy downloadUrlPolicy) - { - Bundle = bundle; - CandidateUrls = candidateUrls; - GamePlatform = gamePlatform; - WatchdogTimeout = watchdogTimeout; - DownloadRetryPolicy = downloadRetryPolicy; - DownloadUrlPolicy = downloadUrlPolicy; - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs.meta deleted file mode 100644 index d1d90e28..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/Internal/LoadWebGameAssetBundleOptions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f71ffbb8bf041e5478862cc179cd7e3f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs deleted file mode 100644 index 2d60cef4..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs +++ /dev/null @@ -1,17 +0,0 @@ - -namespace YooAsset -{ - /// - /// WebGL 游戏平台缓存系统初始化操作 - /// - internal sealed class WGBCInitializeOperation : BCInitializeOperation - { - protected override void InternalStart() - { - SetResult(); - } - protected override void InternalUpdate() - { - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs.meta deleted file mode 100644 index 5e47d9c4..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCInitializeOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5b2ea6881f51a434db344d28e4e5f410 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs deleted file mode 100644 index f96e5686..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs +++ /dev/null @@ -1,100 +0,0 @@ -namespace YooAsset -{ - /// - /// 小游戏平台加载 AssetBundle 操作 - /// - internal sealed class WGBCLoadAssetBundleOperation : BCLoadBundleOperation - { - private enum ESteps - { - None, - LoadBundle, - Done, - } - - private readonly WebGameBundleCache _fileCache; - private readonly BCLoadBundleOptions _options; - private BCLoadBundleOperation _loadBundleOp; - private ESteps _steps = ESteps.None; - - internal WGBCLoadAssetBundleOperation(WebGameBundleCache fileCache, BCLoadBundleOptions options) - { - _fileCache = fileCache; - _options = options; - } - protected override void InternalStart() - { - _steps = ESteps.LoadBundle; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.LoadBundle) - { - if (_loadBundleOp == null) - { - var urls = _fileCache.Config.RemoteService.GetRemoteUrls(_options.Bundle.GetFileName()); - if (_options.Bundle.IsEncrypted) - { - var encryptedOptions = new LoadWebEncryptedAssetBundleOptions( - cacheName: _fileCache.GetType().Name, - bundle: _options.Bundle, - candidateUrls: urls, - assetBundleDecryptor: _fileCache.Config.AssetBundleDecryptor, - downloadBackend: _fileCache.Config.DownloadBackend, - downloadVerifyLevel: _fileCache.Config.DownloadVerifyLevel, - watchdogTimeout: _fileCache.Config.WatchdogTimeout, - downloadRetryPolicy: _fileCache.Config.DownloadRetryPolicy, - downloadUrlPolicy: _fileCache.Config.DownloadUrlPolicy); - _loadBundleOp = new LoadWebEncryptedAssetBundleOperation(encryptedOptions); - } - else - { - var webGameOptions = new LoadWebGameAssetBundleOptions( - bundle: _options.Bundle, - candidateUrls: urls, - gamePlatform: _fileCache.Config.GamePlatform, - watchdogTimeout: _fileCache.Config.WatchdogTimeout, - downloadRetryPolicy: _fileCache.Config.DownloadRetryPolicy, - downloadUrlPolicy: _fileCache.Config.DownloadUrlPolicy); - _loadBundleOp = new LoadWebGameAssetBundleOperation(webGameOptions); - } - - _loadBundleOp.StartOperation(); - AddChildOperation(_loadBundleOp); - } - - _loadBundleOp.UpdateOperation(); - Progress = _loadBundleOp.Progress; - if (_loadBundleOp.IsDone == false) - return; - - if (_loadBundleOp.Status == EOperationStatus.Succeeded) - { - if (_loadBundleOp.BundleHandle == null) - throw new YooInternalException("Loaded bundle handle is null."); - - _steps = ESteps.Done; - SetResult(); - BundleHandle = _loadBundleOp.BundleHandle; - } - else - { - _steps = ESteps.Done; - SetError(_loadBundleOp.Error); - } - } - } - protected override void InternalWaitForCompletion() - { - if (_steps != ESteps.Done) - { - _steps = ESteps.Done; - SetError("WebGL platform does not support synchronous loading."); - YooLogger.LogError(Error); - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs.meta deleted file mode 100644 index 64b284d3..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadAssetBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c5aefbf5ae866434483465f633edf635 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs deleted file mode 100644 index 993a7c1e..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace YooAsset -{ - /// - /// 小游戏平台加载 RawBundle 操作 - /// - internal sealed class WGBCLoadRawBundleOperation : BCLoadBundleOperation - { - private enum ESteps - { - None, - LoadBundle, - Done, - } - - private readonly WebGameBundleCache _fileCache; - private readonly BCLoadBundleOptions _options; - private BCLoadBundleOperation _loadBundleOp; - private ESteps _steps = ESteps.None; - - internal WGBCLoadRawBundleOperation(WebGameBundleCache fileCache, BCLoadBundleOptions options) - { - _fileCache = fileCache; - _options = options; - } - protected override void InternalStart() - { - _steps = ESteps.LoadBundle; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.LoadBundle) - { - if (_loadBundleOp == null) - { - var urls = _fileCache.Config.RemoteService.GetRemoteUrls(_options.Bundle.GetFileName()); - var options = new LoadWebRawBundleOptions( - cacheName: _fileCache.GetType().Name, - bundle: _options.Bundle, - candidateUrls: urls, - rawBundleDecryptor: _fileCache.Config.RawBundleDecryptor, - downloadBackend: _fileCache.Config.DownloadBackend, - downloadVerifyLevel: _fileCache.Config.DownloadVerifyLevel, - watchdogTimeout: _fileCache.Config.WatchdogTimeout, - downloadRetryPolicy: _fileCache.Config.DownloadRetryPolicy, - downloadUrlPolicy: _fileCache.Config.DownloadUrlPolicy); - _loadBundleOp = new LoadWebRawBundleOperation(options); - _loadBundleOp.StartOperation(); - AddChildOperation(_loadBundleOp); - } - - _loadBundleOp.UpdateOperation(); - Progress = _loadBundleOp.Progress; - if (_loadBundleOp.IsDone == false) - return; - - if (_loadBundleOp.Status == EOperationStatus.Succeeded) - { - if (_loadBundleOp.BundleHandle == null) - throw new YooInternalException("Loaded bundle handle is null."); - - _steps = ESteps.Done; - SetResult(); - BundleHandle = _loadBundleOp.BundleHandle; - } - else - { - _steps = ESteps.Done; - SetError(_loadBundleOp.Error); - } - } - } - protected override void InternalWaitForCompletion() - { - if (_steps != ESteps.Done) - { - _steps = ESteps.Done; - SetError("WebGL platform does not support synchronous loading."); - YooLogger.LogError(Error); - } - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs.meta deleted file mode 100644 index 6e188df5..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/Operations/WGBCLoadRawBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4024fa98150c5d4479e93ce88c6c2795 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs deleted file mode 100644 index fe27e966..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System.Collections.Generic; - -namespace YooAsset -{ - /// - /// WebGL 游戏平台缓存系统 - /// - internal class WebGameBundleCache : IBundleCache - { - internal readonly struct Configuration - { - /// - /// 游戏平台接口 - /// - public IWebGamePlatform GamePlatform { get; } - - /// - /// 看门狗超时时间 - /// - public int WatchdogTimeout { get; } - - /// - /// 禁用 Unity 内置网络缓存 - /// - public bool DisableUnityWebCache { get; } - - /// - /// 下载数据校验级别 - /// - public EFileVerifyLevel DownloadVerifyLevel { get; } - - /// - /// AssetBundle 解密器 - /// - public IBundleDecryptor AssetBundleDecryptor { get; } - - /// - /// RawBundle 解密器 - /// - public IBundleDecryptor RawBundleDecryptor { get; } - - /// - /// 远程服务接口 - /// - public IRemoteService RemoteService { get; } - - /// - /// 下载后台接口 - /// - public IDownloadBackend DownloadBackend { get; } - - /// - /// 下载重试判定策略 - /// - public IDownloadRetryPolicy DownloadRetryPolicy { get; } - - /// - /// URL 选择策略 - /// - public IDownloadUrlPolicy DownloadUrlPolicy { get; } - - public Configuration(IWebGamePlatform gamePlatform, int watchdogTimeout, bool disableUnityWebCache, - EFileVerifyLevel downloadVerifyLevel, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor, IRemoteService remoteService, - IDownloadBackend downloadBackend, IDownloadRetryPolicy downloadRetryPolicy, IDownloadUrlPolicy downloadUrlPolicy) - { - GamePlatform = gamePlatform; - WatchdogTimeout = watchdogTimeout; - DisableUnityWebCache = disableUnityWebCache; - DownloadVerifyLevel = downloadVerifyLevel; - AssetBundleDecryptor = assetBundleDecryptor; - RawBundleDecryptor = rawBundleDecryptor; - RemoteService = remoteService; - DownloadBackend = downloadBackend; - DownloadRetryPolicy = downloadRetryPolicy; - DownloadUrlPolicy = downloadUrlPolicy; - } - } - - /// - /// 缓存配置 - /// - internal readonly Configuration Config; - - #region 接口属性 - /// - public string PackageName { get; } - - /// - public string RootPath { get; } - - /// - public bool IsReadOnly { get; } - - /// - public int FileCount { get; } - - /// - public long SpaceOccupied { get; } - #endregion - - /// - /// 创建 WebGameBundleCache 实例 - /// - /// 包裹名称 - /// 缓存根目录 - /// 缓存配置 - public WebGameBundleCache(string packageName, string rootPath, Configuration config) - { - PackageName = packageName; - RootPath = rootPath; - Config = config; - IsReadOnly = true; - } - - /// - public void Dispose() - { - } - /// - public BCInitializeOperation InitializeAsync() - { - var operation = new WGBCInitializeOperation(); - return operation; - } - /// - public BCWriteCacheOperation WriteCacheAsync(BCWriteCacheOptions options) - { - var operation = new BCWriteCacheCompleteOperation($"{nameof(WebGameBundleCache)} is readonly."); - return operation; - } - /// - public BCClearCacheOperation ClearCacheAsync(BCClearCacheOptions options) - { - var operation = new BCClearCacheCompleteOperation(); - return operation; - } - /// - public BCVerifyCacheOperation VerifyCacheAsync(BCVerifyCacheOptions options) - { - var operation = new BCVerifyCacheCompleteOperation(); - return operation; - } - /// - public BCLoadBundleOperation LoadBundleAsync(BCLoadBundleOptions options) - { - if (options.Bundle.GetBundleType() == (int)EBundleType.AssetBundle) - { - var operation = new WGBCLoadAssetBundleOperation(this, options); - return operation; - } - else if (options.Bundle.GetBundleType() == (int)EBundleType.RawBundle) - { - var operation = new WGBCLoadRawBundleOperation(this, options); - return operation; - } - else - { - string error = $"{nameof(WebGameBundleCache)} does not support bundle type: {options.Bundle.GetBundleType()}."; - var operation = new BCLoadBundleErrorOperation(error); - return operation; - } - } - /// - public bool IsCached(string bundleGuid) - { - return true; - } - /// - public string GetCacheFilePath(string bundleGuid) - { - YooLogger.LogWarning($"{nameof(WebGameBundleCache)} does not support local cache file path."); - return null; - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs.meta deleted file mode 100644 index 873fd0d7..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebGameBundleCache/WebGameBundleCache.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ddef4533d379a984c8d1669776147acf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache.meta deleted file mode 100644 index 79fbb997..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bc4cd72a390c1054a99c49a7c501c8f6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations.meta deleted file mode 100644 index 012833d8..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a466429abacca2f40aacb9ab5a9ffebf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs deleted file mode 100644 index 5552e28a..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs +++ /dev/null @@ -1,27 +0,0 @@ - -namespace YooAsset -{ - /// - /// Web远端文件缓存初始化操作 - /// - internal sealed class WRBCInitializeOperation : BCInitializeOperation - { - private readonly WebRemoteBundleCache _fileCache; - - /// - /// 创建 Web 远端缓存初始化操作实例 - /// - /// Web 远端文件缓存系统 - public WRBCInitializeOperation(WebRemoteBundleCache fileCache) - { - _fileCache = fileCache; - } - protected override void InternalStart() - { - SetResult(); - } - protected override void InternalUpdate() - { - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs.meta deleted file mode 100644 index eea7a60c..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCInitializeOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 476dbbea577819a43a807f22bb91f974 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs deleted file mode 100644 index 3832aa58..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs +++ /dev/null @@ -1,110 +0,0 @@ - -namespace YooAsset -{ - /// - /// Web远端文件缓存加载 AssetBundle 操作 - /// - internal sealed class WRBCLoadAssetBundleOperation : BCLoadBundleOperation - { - private enum ESteps - { - None, - LoadBundle, - Done, - } - - private readonly WebRemoteBundleCache _fileCache; - private readonly BCLoadBundleOptions _options; - private BCLoadBundleOperation _loadBundleOp; - private ESteps _steps = ESteps.None; - - /// - /// 创建 WRBCLoadAssetBundleOperation 实例 - /// - /// Web 远端文件缓存系统 - /// 加载资源包操作选项 - public WRBCLoadAssetBundleOperation(WebRemoteBundleCache fileCache, BCLoadBundleOptions options) - { - _fileCache = fileCache; - _options = options; - } - protected override void InternalStart() - { - _steps = ESteps.LoadBundle; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.LoadBundle) - { - if (_loadBundleOp == null) - { - var urls = _fileCache.Config.RemoteService.GetRemoteUrls(_options.Bundle.GetFileName()); - if (_options.Bundle.IsEncrypted) - { - var encryptedOptions = new LoadWebEncryptedAssetBundleOptions( - cacheName: _fileCache.GetType().Name, - bundle: _options.Bundle, - candidateUrls: urls, - assetBundleDecryptor: _fileCache.Config.AssetBundleDecryptor, - downloadBackend: _fileCache.Config.DownloadBackend, - downloadVerifyLevel: _fileCache.Config.DownloadVerifyLevel, - watchdogTimeout: _fileCache.Config.WatchdogTimeout, - downloadRetryPolicy: _fileCache.Config.DownloadRetryPolicy, - downloadUrlPolicy: _fileCache.Config.DownloadUrlPolicy); - _loadBundleOp = new LoadWebEncryptedAssetBundleOperation(encryptedOptions); - } - else - { - var options = new LoadWebAssetBundleOptions( - cacheName: _fileCache.GetType().Name, - bundle: _options.Bundle, - candidateUrls: urls, - assetBundleDecryptor: _fileCache.Config.AssetBundleDecryptor, - downloadBackend: _fileCache.Config.DownloadBackend, - downloadVerifyLevel: _fileCache.Config.DownloadVerifyLevel, - watchdogTimeout: _fileCache.Config.WatchdogTimeout, - disableUnityWebCache: _fileCache.Config.DisableUnityWebCache, - downloadRetryPolicy: _fileCache.Config.DownloadRetryPolicy, - downloadUrlPolicy: _fileCache.Config.DownloadUrlPolicy); - _loadBundleOp = new LoadWebNormalAssetBundleOperation(options); - } - - _loadBundleOp.StartOperation(); - AddChildOperation(_loadBundleOp); - } - - _loadBundleOp.UpdateOperation(); - Progress = _loadBundleOp.Progress; - if (_loadBundleOp.IsDone == false) - return; - - if (_loadBundleOp.Status == EOperationStatus.Succeeded) - { - if (_loadBundleOp.BundleHandle == null) - throw new YooInternalException("Loaded bundle handle is null."); - - _steps = ESteps.Done; - SetResult(); - BundleHandle = _loadBundleOp.BundleHandle; - } - else - { - _steps = ESteps.Done; - SetError(_loadBundleOp.Error); - } - } - } - protected override void InternalWaitForCompletion() - { - if (_steps != ESteps.Done) - { - _steps = ESteps.Done; - SetError("WebGL platform does not support synchronous loading."); - YooLogger.LogError(Error); - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs.meta deleted file mode 100644 index 8fc835f6..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadAssetBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8821049e94e79ff4b9c83c24e7b10d49 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs deleted file mode 100644 index 46cdd1a0..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace YooAsset -{ - /// - /// Web远端文件缓存加载 RawBundle 操作 - /// - internal sealed class WRBCLoadRawBundleOperation : BCLoadBundleOperation - { - private enum ESteps - { - None, - LoadBundle, - Done, - } - - private readonly WebRemoteBundleCache _fileCache; - private readonly BCLoadBundleOptions _options; - private BCLoadBundleOperation _loadBundleOp; - private ESteps _steps = ESteps.None; - - public WRBCLoadRawBundleOperation(WebRemoteBundleCache fileCache, BCLoadBundleOptions options) - { - _fileCache = fileCache; - _options = options; - } - protected override void InternalStart() - { - _steps = ESteps.LoadBundle; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.LoadBundle) - { - if (_loadBundleOp == null) - { - var urls = _fileCache.Config.RemoteService.GetRemoteUrls(_options.Bundle.GetFileName()); - var options = new LoadWebRawBundleOptions( - cacheName: _fileCache.GetType().Name, - bundle: _options.Bundle, - candidateUrls: urls, - rawBundleDecryptor: _fileCache.Config.RawBundleDecryptor, - downloadBackend: _fileCache.Config.DownloadBackend, - downloadVerifyLevel: _fileCache.Config.DownloadVerifyLevel, - watchdogTimeout: _fileCache.Config.WatchdogTimeout, - downloadRetryPolicy: _fileCache.Config.DownloadRetryPolicy, - downloadUrlPolicy: _fileCache.Config.DownloadUrlPolicy); - _loadBundleOp = new LoadWebRawBundleOperation(options); - _loadBundleOp.StartOperation(); - AddChildOperation(_loadBundleOp); - } - - _loadBundleOp.UpdateOperation(); - Progress = _loadBundleOp.Progress; - if (_loadBundleOp.IsDone == false) - return; - - if (_loadBundleOp.Status == EOperationStatus.Succeeded) - { - if (_loadBundleOp.BundleHandle == null) - throw new YooInternalException("Loaded bundle handle is null."); - - _steps = ESteps.Done; - SetResult(); - BundleHandle = _loadBundleOp.BundleHandle; - } - else - { - _steps = ESteps.Done; - SetError(_loadBundleOp.Error); - } - } - } - protected override void InternalWaitForCompletion() - { - if (_steps != ESteps.Done) - { - _steps = ESteps.Done; - SetError("WebGL platform does not support synchronous loading."); - YooLogger.LogError(Error); - } - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs.meta deleted file mode 100644 index 814082cb..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/Operations/WRBCLoadRawBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bf6535c1839c8b04697179268cda275c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs deleted file mode 100644 index 8b536ffa..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace YooAsset -{ - /// - /// Web远端文件缓存系统,用于从远程服务器加载资源。 - /// - internal class WebRemoteBundleCache : IBundleCache - { - internal readonly struct Configuration - { - /// - /// 看门狗超时时间 - /// - public int WatchdogTimeout { get; } - - /// - /// 禁用 Unity 内置网络缓存 - /// - public bool DisableUnityWebCache { get; } - - /// - /// 下载数据校验级别 - /// - public EFileVerifyLevel DownloadVerifyLevel { get; } - - /// - /// AssetBundle 解密器 - /// - public IBundleDecryptor AssetBundleDecryptor { get; } - - /// - /// RawBundle 解密器 - /// - public IBundleDecryptor RawBundleDecryptor { get; } - - /// - /// 远程服务接口 - /// - public IRemoteService RemoteService { get; } - - /// - /// 下载后台接口 - /// - public IDownloadBackend DownloadBackend { get; } - - /// - /// 下载重试判定策略 - /// - public IDownloadRetryPolicy DownloadRetryPolicy { get; } - - /// - /// URL 选择策略 - /// - public IDownloadUrlPolicy DownloadUrlPolicy { get; } - - public Configuration(int watchdogTimeout, bool disableUnityWebCache, - EFileVerifyLevel downloadVerifyLevel, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor, IRemoteService remoteService, - IDownloadBackend downloadBackend, IDownloadRetryPolicy downloadRetryPolicy, IDownloadUrlPolicy downloadUrlPolicy) - { - WatchdogTimeout = watchdogTimeout; - DisableUnityWebCache = disableUnityWebCache; - DownloadVerifyLevel = downloadVerifyLevel; - AssetBundleDecryptor = assetBundleDecryptor; - RawBundleDecryptor = rawBundleDecryptor; - RemoteService = remoteService; - DownloadBackend = downloadBackend; - DownloadRetryPolicy = downloadRetryPolicy; - DownloadUrlPolicy = downloadUrlPolicy; - } - } - - /// - /// 缓存配置 - /// - internal readonly Configuration Config; - - #region 接口属性 - /// - public string PackageName { get; } - - /// - public string RootPath { get; } - - /// - public bool IsReadOnly { get; } - - /// - public int FileCount { get; } - - /// - public long SpaceOccupied { get; } - #endregion - - /// - /// 创建 WebRemoteBundleCache 实例 - /// - /// 包裹名称 - /// 缓存根目录 - /// 缓存配置 - public WebRemoteBundleCache(string packageName, string rootPath, Configuration config) - { - PackageName = packageName; - RootPath = rootPath; - Config = config; - IsReadOnly = true; - } - - /// - public void Dispose() - { - } - /// - public BCInitializeOperation InitializeAsync() - { - var operation = new WRBCInitializeOperation(this); - return operation; - } - /// - public BCWriteCacheOperation WriteCacheAsync(BCWriteCacheOptions options) - { - var operation = new BCWriteCacheCompleteOperation($"{nameof(WebRemoteBundleCache)} is readonly."); - return operation; - } - /// - public BCClearCacheOperation ClearCacheAsync(BCClearCacheOptions options) - { - var operation = new BCClearCacheCompleteOperation(); - return operation; - } - /// - public BCVerifyCacheOperation VerifyCacheAsync(BCVerifyCacheOptions options) - { - var operation = new BCVerifyCacheCompleteOperation(); - return operation; - } - /// - public BCLoadBundleOperation LoadBundleAsync(BCLoadBundleOptions options) - { - if (options.Bundle.GetBundleType() == (int)EBundleType.AssetBundle) - { - var operation = new WRBCLoadAssetBundleOperation(this, options); - return operation; - } - else if (options.Bundle.GetBundleType() == (int)EBundleType.RawBundle) - { - var operation = new WRBCLoadRawBundleOperation(this, options); - return operation; - } - else - { - string error = $"{nameof(WebRemoteBundleCache)} does not support bundle type: {options.Bundle.GetBundleType()}."; - var operation = new BCLoadBundleErrorOperation(error); - return operation; - } - } - /// - public bool IsCached(string bundleGuid) - { - return true; - } - /// - public string GetCacheFilePath(string bundleGuid) - { - YooLogger.LogWarning($"{nameof(WebRemoteBundleCache)} does not support local cache file path."); - return null; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs.meta b/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs.meta deleted file mode 100644 index 8137b7b1..00000000 --- a/Assets/YooAsset/Runtime/BundleCache/Services/WebRemoteBundleCache/WebRemoteBundleCache.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ebc556c0bb6cbe146a502e678761ace1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle.meta b/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle.meta deleted file mode 100644 index e7d5fda4..00000000 --- a/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a5e19370caf42414f91a17249c63b190 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs b/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs deleted file mode 100644 index fa177d25..00000000 --- a/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs +++ /dev/null @@ -1,68 +0,0 @@ -using UnityEngine; -using UnityEngine.SceneManagement; - -namespace YooAsset -{ - /// - /// WebGL 游戏平台 AssetBundle 资源包句柄 - /// - internal sealed class WebGameAssetBundleHandle : IBundleHandle - { - private readonly PackageBundle _packageBundle; - private readonly AssetBundle _assetBundle; - private readonly IWebGamePlatform _platform; - - /// - /// 创建 WebGameAssetBundleHandle 实例 - /// - /// 资源包描述 - /// 已加载的 AssetBundle 对象 - /// 平台实现 - public WebGameAssetBundleHandle(PackageBundle packageBundle, AssetBundle assetBundle, IWebGamePlatform platform) - { - _packageBundle = packageBundle; - _assetBundle = assetBundle; - _platform = platform; - } - - /// - public void UnloadBundle() - { - if (_assetBundle != null) - { - if (_packageBundle.IsEncrypted) - _assetBundle.Unload(true); - else - _platform.UnloadAssetBundle(_assetBundle, true); - } - } - - /// - public BHLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo) - { - var operation = new ABHLoadAssetOperation(_packageBundle, _assetBundle, assetInfo); - return operation; - } - - /// - public BHLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo) - { - var operation = new ABHLoadAllAssetsOperation(_packageBundle, _assetBundle, assetInfo); - return operation; - } - - /// - public BHLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo) - { - var operation = new ABHLoadSubAssetsOperation(_packageBundle, _assetBundle, assetInfo); - return operation; - } - - /// - public BHLoadSceneOperation LoadSceneAsync(AssetInfo assetInfo, LoadSceneParameters loadSceneParams, bool allowSceneActivation) - { - var operation = new ABHLoadSceneOperation(assetInfo, loadSceneParams, allowSceneActivation); - return operation; - } - } -} diff --git a/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs.meta b/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs.meta deleted file mode 100644 index 31b00312..00000000 --- a/Assets/YooAsset/Runtime/BundleHandle/Services/WebGameBundleHandle/WebGameAssetBundleHandle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 37bcfc042801ba74e89e44d47732eb47 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/Compatibility/CompatibleFileSystem.cs b/Assets/YooAsset/Runtime/Compatibility/CompatibleFileSystem.cs index 47a400d6..32f6121c 100644 --- a/Assets/YooAsset/Runtime/Compatibility/CompatibleFileSystem.cs +++ b/Assets/YooAsset/Runtime/Compatibility/CompatibleFileSystem.cs @@ -88,13 +88,31 @@ namespace YooAsset } /// - /// v2.3 WebRemote 文件系统入口 + /// WebRemote 文件系统入口,转发到 WebNetwork 文件系统 /// - [Obsolete("Use CreateDefaultWebRemoteFileSystemParameters(IRemoteService, bool) instead. IWebDecryptionServices is no longer supported.")] + [Obsolete("Use CreateDefaultWebNetworkFileSystemParameters instead.")] + public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteService remoteService, bool disableUnityWebCache) + { + return CreateDefaultWebNetworkFileSystemParameters(remoteService, disableUnityWebCache); + } + + /// + /// WebRemote 文件系统入口,转发到 WebNetwork 文件系统 + /// + [Obsolete("Use CreateDefaultWebNetworkFileSystemParameters instead.")] + public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteService remoteService) + { + return CreateDefaultWebNetworkFileSystemParameters(remoteService); + } + + /// + /// v2.3 WebRemote 文件系统入口,转发到 WebNetwork 文件系统 + /// + [Obsolete("Use CreateDefaultWebNetworkFileSystemParameters(IRemoteService, bool) instead. IWebDecryptionServices is no longer supported.")] public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, IWebDecryptionServices decryptionServices = null, bool disableUnityWebCache = false) { var adapter = remoteServices != null ? new RemoteServicesAdapter(remoteServices) : null; - return CreateDefaultWebRemoteFileSystemParameters(adapter, disableUnityWebCache); + return CreateDefaultWebNetworkFileSystemParameters(adapter, disableUnityWebCache); } } diff --git a/Assets/YooAsset/Runtime/Compatibility/CompatibleResourcePackage.cs b/Assets/YooAsset/Runtime/Compatibility/CompatibleResourcePackage.cs index 051e44f0..4e7491a1 100644 --- a/Assets/YooAsset/Runtime/Compatibility/CompatibleResourcePackage.cs +++ b/Assets/YooAsset/Runtime/Compatibility/CompatibleResourcePackage.cs @@ -71,7 +71,7 @@ namespace YooAsset options.AutoUnloadBundleWhenUnused = wpp.AutoUnloadBundleWhenUnused; options.WebGLForceSyncLoadAsset = wpp.WebGLForceSyncLoadAsset; options.WebServerFileSystemParameters = wpp.WebServerFileSystemParameters; - options.WebRemoteFileSystemParameters = wpp.WebRemoteFileSystemParameters; + options.WebNetworkFileSystemParameters = wpp.WebRemoteFileSystemParameters; var operation = InitializePackageAsync(options); var wrapper = new InitializationOperation(operation); AsyncOperationSystem.StartOperation(PackageName, wrapper); diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest.meta b/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest.meta deleted file mode 100644 index bf36a508..00000000 --- a/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 955bc3e522742f04297343174a663fd6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs b/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs deleted file mode 100644 index 824b58c6..00000000 --- a/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs +++ /dev/null @@ -1,44 +0,0 @@ -using UnityEngine; -using UnityEngine.Networking; - -namespace YooAsset -{ - /// - /// WebGL 游戏平台 AssetBundle 下载器 - /// - /// - /// 创建平台专用请求并提取 AssetBundle 对象 - /// - internal sealed class WebGameAssetBundleRequest : UnityWebRequestBase, IDownloadAssetBundleRequest - { - private readonly IWebGamePlatform _platform; - - /// - /// 下载结果(AssetBundle 对象) - /// - public AssetBundle Result { get; private set; } - - /// - /// 构造 AssetBundle 下载器 - /// - /// 公共请求参数 - /// 游戏平台接口 - public WebGameAssetBundleRequest(DownloadRequestArgs requestArgs, IWebGamePlatform platform) - : base(requestArgs, null) - { - _platform = platform; - } - - protected override UnityWebRequest CreateWebRequest() - { - var request = _platform.CreateAssetBundleRequest(Url); - request.disposeDownloadHandlerOnDispose = true; - return request; - } - - protected override void OnRequestSucceeded(UnityWebRequest webRequest) - { - Result = _platform.ExtractAssetBundle(webRequest); - } - } -} diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs.meta b/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs.meta deleted file mode 100644 index 537e4498..00000000 --- a/Assets/YooAsset/Runtime/DownloadSystem/Services/WebGameRequest/WebGameAssetBundleRequest.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: be6bed6a8d321cd46a34235142571329 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs b/Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs deleted file mode 100644 index 9007bd41..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs +++ /dev/null @@ -1,32 +0,0 @@ -using UnityEngine; -using UnityEngine.Networking; - -namespace YooAsset -{ - /// - /// WebGL 游戏平台接口 - /// - internal interface IWebGamePlatform - { - /// - /// 创建平台专用的 AssetBundle 下载请求 - /// - /// 资源包的远程地址 - /// 已配置的 UnityWebRequest 实例 - UnityWebRequest CreateAssetBundleRequest(string url); - - /// - /// 从已完成的请求中提取 AssetBundle 对象 - /// - /// 已完成下载的 UnityWebRequest - /// 提取到的 AssetBundle,若提取失败则返回 null。 - AssetBundle ExtractAssetBundle(UnityWebRequest request); - - /// - /// 使用平台专用 API 卸载 AssetBundle - /// - /// 待卸载的 AssetBundle 实例 - /// 是否同时卸载所有已加载的资源对象 - void UnloadAssetBundle(AssetBundle assetBundle, bool unloadAll); - } -} diff --git a/Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs.meta deleted file mode 100644 index 5a239b36..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Interfaces/IWebGamePlatform.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7e41f9ae5af23084296179220c99ee37 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem.meta deleted file mode 100644 index b67f3b6f..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ecc61a05185e16f4082069f3d4976a16 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations.meta deleted file mode 100644 index 9bc86275..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6f59bbfac9d9e6f4987496e16bae8b22 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs deleted file mode 100644 index e60c802f..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs +++ /dev/null @@ -1,96 +0,0 @@ -namespace YooAsset -{ - /// - /// WebGL 游戏平台文件系统初始化操作 - /// - internal sealed class WGFSInitializeOperation : FSInitializeOperation - { - private enum ESteps - { - None, - CheckPlatform, - CheckParameter, - InitializeBundleCache, - Done, - } - - private readonly WebGameFileSystem _fileSystem; - private BCInitializeOperation _initializeBundleCacheOp; - private ESteps _steps = ESteps.None; - - internal WGFSInitializeOperation(WebGameFileSystem fileSystem) - { - _fileSystem = fileSystem; - } - protected override void InternalStart() - { - _steps = ESteps.CheckPlatform; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.CheckPlatform) - { -#if !UNITY_WEBGL - _steps = ESteps.Done; - SetError($"{nameof(WebGameFileSystem)} only supports the WebGL platform."); -#else - _steps = ESteps.CheckParameter; -#endif - } - - if (_steps == ESteps.CheckParameter) - { - if (_fileSystem.RemoteService == null) - { - _steps = ESteps.Done; - SetError($"{nameof(IRemoteService)} is null."); - return; - } - - // 检查URL双斜杠 - // 注意:双斜杠会导致某小游戏平台加载文件失败,但网络请求又不返回失败! - var testUrls = _fileSystem.RemoteService.GetRemoteUrls("test.bundle"); - foreach (var url in testUrls) - { - if (PathUtility.ContainsDoubleSlashes(url)) - { - _steps = ESteps.Done; - SetError($"{nameof(IRemoteService)} returned URL contains double slashes: '{url}'."); - return; - } - } - - _steps = ESteps.InitializeBundleCache; - } - - if (_steps == ESteps.InitializeBundleCache) - { - if (_initializeBundleCacheOp == null) - { - _initializeBundleCacheOp = _fileSystem.BundleCache.InitializeAsync(); - _initializeBundleCacheOp.StartOperation(); - AddChildOperation(_initializeBundleCacheOp); - } - - _initializeBundleCacheOp.UpdateOperation(); - Progress = _initializeBundleCacheOp.Progress; - if (_initializeBundleCacheOp.IsDone == false) - return; - - if (_initializeBundleCacheOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.Done; - SetResult(); - } - else - { - _steps = ESteps.Done; - SetError(_initializeBundleCacheOp.Error); - } - } - } - } -} diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs.meta deleted file mode 100644 index 7f1874fe..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSInitializeOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4c67db74d2670a84abf48b4b3dad3227 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs deleted file mode 100644 index d9ecea78..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace YooAsset -{ - /// - /// WebGL 游戏平台加载资源包操作 - /// - internal sealed class WGFSLoadPackageBundleOperation : FSLoadPackageBundleOperation - { - private enum ESteps - { - None, - LoadBundle, - Done, - } - - private readonly WebGameFileSystem _fileSystem; - private readonly FSLoadPackageBundleOptions _options; - private BCLoadBundleOperation _loadBundleOp; - private ESteps _steps = ESteps.None; - - internal WGFSLoadPackageBundleOperation(WebGameFileSystem fileSystem, FSLoadPackageBundleOptions options) - { - _fileSystem = fileSystem; - _options = options; - } - protected override void InternalStart() - { - _steps = ESteps.LoadBundle; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.LoadBundle) - { - if (_loadBundleOp == null) - { - _loadBundleOp = _fileSystem.BundleCache.LoadBundleAsync(_options.ConvertTo()); - _loadBundleOp.StartOperation(); - AddChildOperation(_loadBundleOp); - } - - _loadBundleOp.UpdateOperation(); - Progress = _loadBundleOp.Progress; - if (_loadBundleOp.IsDone == false) - return; - - if (_loadBundleOp.Status == EOperationStatus.Succeeded) - { - if (_loadBundleOp.BundleHandle == null) - { - _steps = ESteps.Done; - SetError("Fatal error: loaded bundle handle is null."); - } - else - { - _steps = ESteps.Done; - SetResult(); - BundleHandle = _loadBundleOp.BundleHandle; - } - } - else - { - _steps = ESteps.Done; - SetError(_loadBundleOp.Error); - } - } - } - protected override void InternalWaitForCompletion() - { - if (_steps != ESteps.Done) - { - _steps = ESteps.Done; - SetError("WebGL platform does not support synchronous loading."); - YooLogger.LogError(Error); - } - } - } -} diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs.meta deleted file mode 100644 index 0ef97fb3..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4330e6c76bd8f6146bdba6c5b6715469 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs deleted file mode 100644 index d409bca1..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs +++ /dev/null @@ -1,106 +0,0 @@ -namespace YooAsset -{ - /// - /// WebGL 游戏平台加载包裹清单操作 - /// - internal sealed class WGFSLoadPackageManifestOperation : FSLoadPackageManifestOperation - { - private enum ESteps - { - None, - RequestPackageHash, - LoadPackageManifest, - Done, - } - - private readonly WebGameFileSystem _fileSystem; - private readonly string _packageVersion; - private readonly int _timeout; - private RequestWebPackageHashOperation _requestWebPackageHashOp; - private LoadWebPackageManifestOperation _loadWebPackageManifestOp; - private ESteps _steps = ESteps.None; - - internal WGFSLoadPackageManifestOperation(WebGameFileSystem fileSystem, string packageVersion, int timeout) - { - _fileSystem = fileSystem; - _packageVersion = packageVersion; - _timeout = timeout; - } - protected override void InternalStart() - { - _steps = ESteps.RequestPackageHash; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.RequestPackageHash) - { - if (_requestWebPackageHashOp == null) - { - var options = new RequestWebPackageHashOptions( - packageName: _fileSystem.PackageName, - packageVersion: _packageVersion, - timeout: _timeout, - remoteService: _fileSystem.RemoteService, - downloadBackend: _fileSystem.DownloadBackend, - downloadUrlPolicy: _fileSystem.DownloadUrlPolicy); - _requestWebPackageHashOp = new RequestWebPackageHashOperation(options); - _requestWebPackageHashOp.StartOperation(); - AddChildOperation(_requestWebPackageHashOp); - } - - _requestWebPackageHashOp.UpdateOperation(); - if (_requestWebPackageHashOp.IsDone == false) - return; - - if (_requestWebPackageHashOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.LoadPackageManifest; - } - else - { - _steps = ESteps.Done; - SetError(_requestWebPackageHashOp.Error); - } - } - - if (_steps == ESteps.LoadPackageManifest) - { - if (_loadWebPackageManifestOp == null) - { - var options = new LoadWebPackageManifestOptions( - packageName: _fileSystem.PackageName, - packageVersion: _packageVersion, - packageHash: _requestWebPackageHashOp.PackageHash, - timeout: _timeout, - remoteService: _fileSystem.RemoteService, - manifestDecryptor: _fileSystem.ManifestDecryptor, - downloadBackend: _fileSystem.DownloadBackend, - downloadUrlPolicy: _fileSystem.DownloadUrlPolicy); - _loadWebPackageManifestOp = new LoadWebPackageManifestOperation(options); - _loadWebPackageManifestOp.StartOperation(); - AddChildOperation(_loadWebPackageManifestOp); - } - - _loadWebPackageManifestOp.UpdateOperation(); - Progress = _loadWebPackageManifestOp.Progress; - if (_loadWebPackageManifestOp.IsDone == false) - return; - - if (_loadWebPackageManifestOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.Done; - Manifest = _loadWebPackageManifestOp.Manifest; - SetResult(); - } - else - { - _steps = ESteps.Done; - SetError(_loadWebPackageManifestOp.Error); - } - } - } - } -} diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs.meta deleted file mode 100644 index 91a957af..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSLoadPackageManifestOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 94158cfc4223d4f4ca4883d097aad775 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs deleted file mode 100644 index 3e2cf9e1..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs +++ /dev/null @@ -1,71 +0,0 @@ -namespace YooAsset -{ - /// - /// WebGL 游戏平台请求包裹版本操作 - /// - internal sealed class WGFSRequestPackageVersionOperation : FSRequestPackageVersionOperation - { - private enum ESteps - { - None, - RequestPackageVersion, - Done, - } - - private readonly WebGameFileSystem _fileSystem; - private readonly bool _appendTimeTicks; - private readonly int _timeout; - private RequestWebPackageVersionOperation _requestWebPackageVersionOp; - private ESteps _steps = ESteps.None; - - internal WGFSRequestPackageVersionOperation(WebGameFileSystem fileSystem, bool appendTimeTicks, int timeout) - { - _fileSystem = fileSystem; - _appendTimeTicks = appendTimeTicks; - _timeout = timeout; - } - protected override void InternalStart() - { - _steps = ESteps.RequestPackageVersion; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.RequestPackageVersion) - { - if (_requestWebPackageVersionOp == null) - { - var options = new RequestWebPackageVersionOptions( - packageName: _fileSystem.PackageName, - appendTimeTicks: _appendTimeTicks, - timeout: _timeout, - remoteService: _fileSystem.RemoteService, - downloadBackend: _fileSystem.DownloadBackend, - downloadUrlPolicy: _fileSystem.DownloadUrlPolicy); - _requestWebPackageVersionOp = new RequestWebPackageVersionOperation(options); - _requestWebPackageVersionOp.StartOperation(); - AddChildOperation(_requestWebPackageVersionOp); - } - - _requestWebPackageVersionOp.UpdateOperation(); - Progress = _requestWebPackageVersionOp.Progress; - if (_requestWebPackageVersionOp.IsDone == false) - return; - - if (_requestWebPackageVersionOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.Done; - PackageVersion = _requestWebPackageVersionOp.PackageVersion; - SetResult(); - } - else - { - _steps = ESteps.Done; - SetError(_requestWebPackageVersionOp.Error); - } - } - } - } -} diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs.meta deleted file mode 100644 index 43126b13..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/Operations/WGFSRequestPackageVersionOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 82b50b3ee5b8b114697a65275691f883 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs deleted file mode 100644 index a8d07b16..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace YooAsset -{ - /// - /// WebGL 游戏平台文件系统抽象基类,封装各小游戏平台的公共逻辑 - /// - internal abstract class WebGameFileSystem : IFileSystem - { - /// - /// 平台实现实例 - /// - internal IWebGamePlatform Platform { get; private set; } - - /// - /// 缓存系统 - /// - public IBundleCache BundleCache { get; private set; } - - /// - /// 下载后台接口 - /// - public IDownloadBackend DownloadBackend { get; private set; } - - /// - /// 包裹名称 - /// - public string PackageName { get; private set; } - - #region 自定义参数 - /// - /// 自定义参数:禁用 Unity 内置网络缓存 - /// - public bool DisableUnityWebCache { get; private set; } = true; - - /// - /// 自定义参数:下载看门狗超时时间(秒) - /// - public int DownloadWatchdogTimeout { get; private set; } = 0; - - /// - /// 自定义参数:下载数据校验级别 - /// - public EFileVerifyLevel DownloadVerifyLevel { get; private set; } = EFileVerifyLevel.Middle; - - /// - /// 自定义参数:远端资源服务 - /// - public IRemoteService RemoteService { get; private set; } - - /// - /// 自定义参数:资源包解密器 - /// - public IBundleDecryptor AssetBundleDecryptor { get; private set; } - - /// - /// 自定义参数:RawBundle 解密器 - /// - public IBundleDecryptor RawBundleDecryptor { get; private set; } - - /// - /// 自定义参数:资源清单解密器 - /// - public IManifestDecryptor ManifestDecryptor { get; private set; } - - /// - /// 自定义参数:下载重试策略 - /// - public IDownloadRetryPolicy DownloadRetryPolicy { get; private set; } - - /// - /// 自定义参数:URL 选择策略 - /// - public IDownloadUrlPolicy DownloadUrlPolicy { get; private set; } - #endregion - - /// - public virtual FSInitializeOperation InitializeAsync() - { - var operation = new WGFSInitializeOperation(this); - return operation; - } - /// - public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(FSRequestPackageVersionOptions options) - { - var operation = new WGFSRequestPackageVersionOperation(this, options.AppendTimeTicks, options.Timeout); - return operation; - } - /// - public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(FSLoadPackageManifestOptions options) - { - var operation = new WGFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout); - return operation; - } - /// - public virtual FSLoadPackageBundleOperation LoadPackageBundleAsync(FSLoadPackageBundleOptions options) - { - var operation = new WGFSLoadPackageBundleOperation(this, options); - return operation; - } - /// - public virtual FSEnsurePackageBundleOperation EnsurePackageBundleAsync(FSEnsurePackageBundleOptions options) - { - var operation = new FSEnsurePackageBundleFailureOperation($"{nameof(WebGameFileSystem)} does not support ensure bundle file operation."); - return operation; - } - /// - public virtual FSDownloadBundleOperation DownloadBundleAsync(FSDownloadBundleOptions options) - { - var operation = new FSDownloadBundleCompleteOperation($"{nameof(WebGameFileSystem)} does not support download operation."); - return operation; - } - /// - public virtual FSClearCacheOperation ClearCacheAsync(FSClearCacheOptions options) - { - var operation = new FSClearCacheCompleteOperation(); - return operation; - } - - /// - public virtual void SetParameter(string paramName, object value) - { - if (paramName == nameof(EFileSystemParameter.DownloadBackend)) - { - DownloadBackend = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DisableUnityWebCache)) - { - DisableUnityWebCache = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DownloadWatchdogTimeout)) - { - int convertValue = FileSystemHelper.CastParameter(paramName, value); - DownloadWatchdogTimeout = Mathf.Max(convertValue, 0); - } - else if (paramName == nameof(EFileSystemParameter.FileVerifyLevel)) - { - DownloadVerifyLevel = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.RemoteService)) - { - RemoteService = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.AssetbundleDecryptor)) - { - AssetBundleDecryptor = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.RawbundleDecryptor)) - { - RawBundleDecryptor = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.ManifestDecryptor)) - { - ManifestDecryptor = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DownloadRetryPolicy)) - { - DownloadRetryPolicy = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DownloadUrlPolicy)) - { - DownloadUrlPolicy = FileSystemHelper.CastParameter(paramName, value); - } - else - { - throw new ArgumentException($"Unrecognized parameter name: '{paramName}'.", nameof(paramName)); - } - } - /// - public virtual void OnCreate(string packageName, string packageRoot) - { - PackageName = packageName; - - if (string.IsNullOrEmpty(packageRoot)) - { - throw new ArgumentException("The package root for mini game cache must be configured.", nameof(packageRoot)); - } - - // 创建默认的下载后台接口 - if (DownloadBackend == null) - DownloadBackend = new UnityWebRequestBackend(); - - // 创建默认的下载重试策略 - if (DownloadRetryPolicy == null) - DownloadRetryPolicy = new DefaultDownloadRetryPolicy(); - - // 创建默认的 URL 选择策略 - if (DownloadUrlPolicy == null) - DownloadUrlPolicy = new DefaultDownloadUrlPolicy(); - - // 创建Web游戏缓存系统 - Platform = CreatePlatform(packageRoot); - var cacheConfig = new WebGameBundleCache.Configuration( - gamePlatform: Platform, - watchdogTimeout: DownloadWatchdogTimeout, - disableUnityWebCache: DisableUnityWebCache, - downloadVerifyLevel: DownloadVerifyLevel, - assetBundleDecryptor: AssetBundleDecryptor, - rawBundleDecryptor: RawBundleDecryptor, - remoteService: RemoteService, - downloadBackend: DownloadBackend, - downloadRetryPolicy: DownloadRetryPolicy, - downloadUrlPolicy: DownloadUrlPolicy); - BundleCache = new WebGameBundleCache(packageName, packageRoot, cacheConfig); - } - /// - public virtual void OnDestroy() - { - if (BundleCache != null) - { - BundleCache.Dispose(); - BundleCache = null; - } - - if (DownloadBackend != null) - { - DownloadBackend.Dispose(); - DownloadBackend = null; - } - } - - /// - public virtual bool CanAcceptBundle(PackageBundle bundle) - { - // 注意:保底加载! - return true; - } - /// - public virtual bool IsDownloadRequired(PackageBundle bundle) - { - return false; - } - /// - public virtual bool IsUnpackRequired(PackageBundle bundle) - { - return false; - } - /// - public virtual bool IsImportRequired(PackageBundle bundle) - { - return false; - } - - /// - /// 创建平台实现实例 - /// - /// 包裹缓存根目录 - /// 平台实现实例 - protected abstract IWebGamePlatform CreatePlatform(string packageRoot); - } -} diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs.meta deleted file mode 100644 index 60015a49..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebGameFileSystem/WebGameFileSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 593436dc827a65c4a81aff2d7805db07 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem.meta deleted file mode 100644 index 8e32bad0..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2bf1355f3cbe3d543b53bd9553bba02c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations.meta deleted file mode 100644 index e8afc8be..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1086ea45b8b84fe43ba1ef69b4f813dc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs deleted file mode 100644 index 8fc625a0..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs +++ /dev/null @@ -1,84 +0,0 @@ - -namespace YooAsset -{ - /// - /// Web远端文件系统的初始化操作 - /// - internal sealed class WRFSInitializeOperation : FSInitializeOperation - { - private enum ESteps - { - None, - CheckPlatform, - CheckParameter, - InitializeBundleCache, - Done, - } - - private readonly WebRemoteFileSystem _fileSystem; - private BCInitializeOperation _initializeBundleCacheOp; - private ESteps _steps = ESteps.None; - - public WRFSInitializeOperation(WebRemoteFileSystem fileSystem) - { - _fileSystem = fileSystem; - } - protected override void InternalStart() - { - _steps = ESteps.CheckPlatform; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.CheckPlatform) - { -#if !UNITY_WEBGL - _steps = ESteps.Done; - SetError($"{nameof(WebRemoteFileSystem)} only supports the WebGL platform."); -#else - _steps = ESteps.CheckParameter; -#endif - } - - if (_steps == ESteps.CheckParameter) - { - if (_fileSystem.RemoteService == null) - { - _steps = ESteps.Done; - SetError($"{nameof(IRemoteService)} is null."); - return; - } - - _steps = ESteps.InitializeBundleCache; - } - - if (_steps == ESteps.InitializeBundleCache) - { - if (_initializeBundleCacheOp == null) - { - _initializeBundleCacheOp = _fileSystem.BundleCache.InitializeAsync(); - _initializeBundleCacheOp.StartOperation(); - AddChildOperation(_initializeBundleCacheOp); - } - - _initializeBundleCacheOp.UpdateOperation(); - Progress = _initializeBundleCacheOp.Progress; - if (_initializeBundleCacheOp.IsDone == false) - return; - - if (_initializeBundleCacheOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.Done; - SetResult(); - } - else - { - _steps = ESteps.Done; - SetError(_initializeBundleCacheOp.Error); - } - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs.meta deleted file mode 100644 index ec724288..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSInitializeOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f30b92e4f3b9e594ca0481128b56cc21 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs deleted file mode 100644 index fff6d10b..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs +++ /dev/null @@ -1,80 +0,0 @@ - -namespace YooAsset -{ - /// - /// Web远端文件系统的加载资源包操作 - /// - internal sealed class WRFSLoadPackageBundleOperation : FSLoadPackageBundleOperation - { - private enum ESteps - { - None, - LoadBundle, - Done, - } - - private readonly WebRemoteFileSystem _fileSystem; - private readonly FSLoadPackageBundleOptions _options; - private BCLoadBundleOperation _loadBundleOp; - private ESteps _steps = ESteps.None; - - internal WRFSLoadPackageBundleOperation(WebRemoteFileSystem fileSystem, FSLoadPackageBundleOptions options) - { - _fileSystem = fileSystem; - _options = options; - } - protected override void InternalStart() - { - _steps = ESteps.LoadBundle; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.LoadBundle) - { - if (_loadBundleOp == null) - { - _loadBundleOp = _fileSystem.BundleCache.LoadBundleAsync(_options.ConvertTo()); - _loadBundleOp.StartOperation(); - AddChildOperation(_loadBundleOp); - } - - _loadBundleOp.UpdateOperation(); - Progress = _loadBundleOp.Progress; - if (_loadBundleOp.IsDone == false) - return; - - if (_loadBundleOp.Status == EOperationStatus.Succeeded) - { - if (_loadBundleOp.BundleHandle == null) - { - _steps = ESteps.Done; - SetError("Fatal error: loaded bundle handle is null."); - } - else - { - _steps = ESteps.Done; - SetResult(); - BundleHandle = _loadBundleOp.BundleHandle; - } - } - else - { - _steps = ESteps.Done; - SetError(_loadBundleOp.Error); - } - } - } - protected override void InternalWaitForCompletion() - { - if (_steps != ESteps.Done) - { - _steps = ESteps.Done; - SetError("WebGL platform does not support synchronous loading."); - YooLogger.LogError(Error); - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs.meta deleted file mode 100644 index 0295664b..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageBundleOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 270b776fd379b0f45bc602c845720733 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs deleted file mode 100644 index 897ae581..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs +++ /dev/null @@ -1,108 +0,0 @@ - -namespace YooAsset -{ - /// - /// Web远端文件系统的加载包裹清单操作 - /// - internal sealed class WRFSLoadPackageManifestOperation : FSLoadPackageManifestOperation - { - private enum ESteps - { - None, - RequestPackageHash, - LoadPackageManifest, - Done, - } - - private readonly WebRemoteFileSystem _fileSystem; - private readonly string _packageVersion; - private readonly int _timeout; - private RequestWebPackageHashOperation _requestWebPackageHashOp; - private LoadWebPackageManifestOperation _loadWebPackageManifestOp; - private ESteps _steps = ESteps.None; - - - public WRFSLoadPackageManifestOperation(WebRemoteFileSystem fileSystem, string packageVersion, int timeout) - { - _fileSystem = fileSystem; - _packageVersion = packageVersion; - _timeout = timeout; - } - protected override void InternalStart() - { - _steps = ESteps.RequestPackageHash; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.RequestPackageHash) - { - if (_requestWebPackageHashOp == null) - { - var options = new RequestWebPackageHashOptions( - packageName: _fileSystem.PackageName, - packageVersion: _packageVersion, - timeout: _timeout, - remoteService: _fileSystem.RemoteService, - downloadBackend: _fileSystem.DownloadBackend, - downloadUrlPolicy: _fileSystem.DownloadUrlPolicy); - _requestWebPackageHashOp = new RequestWebPackageHashOperation(options); - _requestWebPackageHashOp.StartOperation(); - AddChildOperation(_requestWebPackageHashOp); - } - - _requestWebPackageHashOp.UpdateOperation(); - if (_requestWebPackageHashOp.IsDone == false) - return; - - if (_requestWebPackageHashOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.LoadPackageManifest; - } - else - { - _steps = ESteps.Done; - SetError(_requestWebPackageHashOp.Error); - } - } - - if (_steps == ESteps.LoadPackageManifest) - { - if (_loadWebPackageManifestOp == null) - { - var options = new LoadWebPackageManifestOptions( - packageName: _fileSystem.PackageName, - packageVersion: _packageVersion, - packageHash: _requestWebPackageHashOp.PackageHash, - timeout: _timeout, - remoteService: _fileSystem.RemoteService, - manifestDecryptor: _fileSystem.ManifestDecryptor, - downloadBackend: _fileSystem.DownloadBackend, - downloadUrlPolicy: _fileSystem.DownloadUrlPolicy); - _loadWebPackageManifestOp = new LoadWebPackageManifestOperation(options); - _loadWebPackageManifestOp.StartOperation(); - AddChildOperation(_loadWebPackageManifestOp); - } - - _loadWebPackageManifestOp.UpdateOperation(); - Progress = _loadWebPackageManifestOp.Progress; - if (_loadWebPackageManifestOp.IsDone == false) - return; - - if (_loadWebPackageManifestOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.Done; - Manifest = _loadWebPackageManifestOp.Manifest; - SetResult(); - } - else - { - _steps = ESteps.Done; - SetError(_loadWebPackageManifestOp.Error); - } - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs.meta deleted file mode 100644 index 0b4295ed..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSLoadPackageManifestOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2611f6fbc97de1a4d9a38116045d4faf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs deleted file mode 100644 index aa9997d7..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs +++ /dev/null @@ -1,73 +0,0 @@ - -namespace YooAsset -{ - /// - /// Web远端文件系统的查询包裹版本操作 - /// - internal sealed class WRFSRequestPackageVersionOperation : FSRequestPackageVersionOperation - { - private enum ESteps - { - None, - RequestPackageVersion, - Done, - } - - private readonly WebRemoteFileSystem _fileSystem; - private readonly bool _appendTimeTicks; - private readonly int _timeout; - private RequestWebPackageVersionOperation _requestWebPackageVersionOp; - private ESteps _steps = ESteps.None; - - - internal WRFSRequestPackageVersionOperation(WebRemoteFileSystem fileSystem, bool appendTimeTicks, int timeout) - { - _fileSystem = fileSystem; - _appendTimeTicks = appendTimeTicks; - _timeout = timeout; - } - protected override void InternalStart() - { - _steps = ESteps.RequestPackageVersion; - } - protected override void InternalUpdate() - { - if (_steps == ESteps.None || _steps == ESteps.Done) - return; - - if (_steps == ESteps.RequestPackageVersion) - { - if (_requestWebPackageVersionOp == null) - { - var options = new RequestWebPackageVersionOptions( - packageName: _fileSystem.PackageName, - appendTimeTicks: _appendTimeTicks, - timeout: _timeout, - remoteService: _fileSystem.RemoteService, - downloadBackend: _fileSystem.DownloadBackend, - downloadUrlPolicy: _fileSystem.DownloadUrlPolicy); - _requestWebPackageVersionOp = new RequestWebPackageVersionOperation(options); - _requestWebPackageVersionOp.StartOperation(); - AddChildOperation(_requestWebPackageVersionOp); - } - - _requestWebPackageVersionOp.UpdateOperation(); - Progress = _requestWebPackageVersionOp.Progress; - if (_requestWebPackageVersionOp.IsDone == false) - return; - - if (_requestWebPackageVersionOp.Status == EOperationStatus.Succeeded) - { - _steps = ESteps.Done; - PackageVersion = _requestWebPackageVersionOp.PackageVersion; - SetResult(); - } - else - { - _steps = ESteps.Done; - SetError(_requestWebPackageVersionOp.Error); - } - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs.meta deleted file mode 100644 index 905dbaa4..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/Operations/WRFSRequestPackageVersionOperation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d1c5335974b2432458ed902e20cc954e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs deleted file mode 100644 index 99d8a11e..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs +++ /dev/null @@ -1,249 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace YooAsset -{ - /// - /// Web远端文件系统,管理 WebRemote 平台的远程文件系统访问。 - /// - internal class WebRemoteFileSystem : IFileSystem - { - /// - /// Web 文件缓存系统 - /// - public IBundleCache BundleCache { get; private set; } - - /// - /// 下载后台接口 - /// - public IDownloadBackend DownloadBackend { get; private set; } - - /// - /// 包裹名称 - /// - public string PackageName { get; private set; } - - #region 自定义参数 - /// - /// 自定义参数:UnityWebRequest 创建委托 - /// - public UnityWebRequestCreator WebRequestCreator { get; private set; } - - /// - /// 自定义参数:禁用 Unity 内置网络缓存 - /// - public bool DisableUnityWebCache { get; private set; } = false; - - /// - /// 自定义参数:下载任务的看门狗机制超时时间 - /// - public int DownloadWatchdogTimeout { get; private set; } = 0; - - /// - /// 自定义参数:下载的资源包数据的校验级别 - /// - public EFileVerifyLevel DownloadVerifyLevel { get; private set; } = EFileVerifyLevel.Middle; - - /// - /// 支持跨域下载的远程服务接口实例 - /// - public IRemoteService RemoteService { get; private set; } - - /// - /// 自定义参数:AssetBundle 解密器 - /// - public IBundleDecryptor AssetBundleDecryptor { get; private set; } - - /// - /// 自定义参数:RawBundle 解密器 - /// - public IBundleDecryptor RawBundleDecryptor { get; private set; } - - /// - /// 自定义参数:资源清单解密器 - /// - public IManifestDecryptor ManifestDecryptor { get; private set; } - - /// - /// 自定义参数:下载重试判定策略 - /// - public IDownloadRetryPolicy DownloadRetryPolicy { get; private set; } - - /// - /// 自定义参数:URL 选择策略 - /// - public IDownloadUrlPolicy DownloadUrlPolicy { get; private set; } - #endregion - - /// - /// 创建实例 - /// - public WebRemoteFileSystem() - { - } - /// - public FSInitializeOperation InitializeAsync() - { - var operation = new WRFSInitializeOperation(this); - return operation; - } - /// - public FSRequestPackageVersionOperation RequestPackageVersionAsync(FSRequestPackageVersionOptions options) - { - var operation = new WRFSRequestPackageVersionOperation(this, options.AppendTimeTicks, options.Timeout); - return operation; - } - /// - public FSLoadPackageManifestOperation LoadPackageManifestAsync(FSLoadPackageManifestOptions options) - { - var operation = new WRFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout); - return operation; - } - /// - public FSLoadPackageBundleOperation LoadPackageBundleAsync(FSLoadPackageBundleOptions options) - { - var operation = new WRFSLoadPackageBundleOperation(this, options); - return operation; - } - /// - public FSEnsurePackageBundleOperation EnsurePackageBundleAsync(FSEnsurePackageBundleOptions options) - { - var operation = new FSEnsurePackageBundleFailureOperation($"{nameof(WebRemoteFileSystem)} does not support ensure bundle file operation."); - return operation; - } - /// - public FSDownloadBundleOperation DownloadBundleAsync(FSDownloadBundleOptions options) - { - var operation = new FSDownloadBundleCompleteOperation($"{nameof(WebRemoteFileSystem)} does not support download operation."); - return operation; - } - /// - public FSClearCacheOperation ClearCacheAsync(FSClearCacheOptions options) - { - var operation = new FSClearCacheCompleteOperation(); - return operation; - } - - /// - public void SetParameter(string paramName, object value) - { - if (paramName == nameof(EFileSystemParameter.DownloadBackend)) - { - DownloadBackend = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.UnityWebRequestCreator)) - { - WebRequestCreator = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DisableUnityWebCache)) - { - DisableUnityWebCache = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DownloadWatchdogTimeout)) - { - int convertValue = FileSystemHelper.CastParameter(paramName, value); - DownloadWatchdogTimeout = Mathf.Max(convertValue, 0); - } - else if (paramName == nameof(EFileSystemParameter.FileVerifyLevel)) - { - DownloadVerifyLevel = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.RemoteService)) - { - RemoteService = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.AssetbundleDecryptor)) - { - AssetBundleDecryptor = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.RawbundleDecryptor)) - { - RawBundleDecryptor = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.ManifestDecryptor)) - { - ManifestDecryptor = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DownloadRetryPolicy)) - { - DownloadRetryPolicy = FileSystemHelper.CastParameter(paramName, value); - } - else if (paramName == nameof(EFileSystemParameter.DownloadUrlPolicy)) - { - DownloadUrlPolicy = FileSystemHelper.CastParameter(paramName, value); - } - else - { - throw new ArgumentException($"Unrecognized parameter name: '{paramName}'.", nameof(paramName)); - } - } - /// - public void OnCreate(string packageName, string packageRoot) - { - PackageName = packageName; - - // 创建默认的下载后台接口 - if (DownloadBackend == null) - DownloadBackend = new UnityWebRequestBackend(WebRequestCreator); - - // 创建默认的下载重试策略 - if (DownloadRetryPolicy == null) - DownloadRetryPolicy = new DefaultDownloadRetryPolicy(); - - // 创建默认的 URL 选择策略 - if (DownloadUrlPolicy == null) - DownloadUrlPolicy = new DefaultDownloadUrlPolicy(); - - // 创建Web文件缓存系统 - var cacheConfig = new WebRemoteBundleCache.Configuration( - watchdogTimeout: DownloadWatchdogTimeout, - disableUnityWebCache: DisableUnityWebCache, - downloadVerifyLevel: DownloadVerifyLevel, - assetBundleDecryptor: AssetBundleDecryptor, - rawBundleDecryptor: RawBundleDecryptor, - remoteService: RemoteService, - downloadBackend: DownloadBackend, - downloadRetryPolicy: DownloadRetryPolicy, - downloadUrlPolicy: DownloadUrlPolicy); - BundleCache = new WebRemoteBundleCache(packageName, packageRoot, cacheConfig); - } - /// - public void OnDestroy() - { - if (BundleCache != null) - { - BundleCache.Dispose(); - BundleCache = null; - } - - if (DownloadBackend != null) - { - DownloadBackend.Dispose(); - DownloadBackend = null; - } - } - - /// - public bool CanAcceptBundle(PackageBundle bundle) - { - // 注意:保底加载! - return true; - } - /// - public bool IsDownloadRequired(PackageBundle bundle) - { - return false; - } - /// - public bool IsUnpackRequired(PackageBundle bundle) - { - return false; - } - /// - public bool IsImportRequired(PackageBundle bundle) - { - return false; - } - } -} diff --git a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs.meta b/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs.meta deleted file mode 100644 index 9b19d12b..00000000 --- a/Assets/YooAsset/Runtime/FileSystem/Services/WebRemoteFileSystem/WebRemoteFileSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f511714bfc7c1104aa6200ee0826e9e3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayFileSystem.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayFileSystem.cs index 0f32aaaf..260cc020 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayFileSystem.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayFileSystem.cs @@ -1,43 +1,32 @@ #if UNITY_WEBGL && UNITY_ALIMINIGAME using YooAsset; -using AlipaySdk; public static class AlipayFileSystemCreater { - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService) { - string fileSystemClass = $"{nameof(AlipayFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) { - string fileSystemClass = $"{nameof(AlipayFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) { - string fileSystemClass = $"{nameof(AlipayFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); return fileSystemParams; } -} -/// -/// 支付宝小游戏文件系统 -/// -internal class AlipayFileSystem : WebGameFileSystem -{ - protected override IWebGamePlatform CreatePlatform(string packageRoot) + private static FileSystemParameters CreateBaseFileSystemParameters(IRemoteService remoteService) { - return new AlipayPlatform(); + var fileSystemParams = FileSystemParameters.CreateDefaultWebNetworkFileSystemParameters(remoteService, true); + fileSystemParams.AddParameter(EFileSystemParameter.WebPlatformStrategy, new AlipayPlatform()); + return fileSystemParams; } } #endif diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayPlatform.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayPlatform.cs index e230aa3e..5e9c2cff 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayPlatform.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayPlatform.cs @@ -8,12 +8,14 @@ using AlipaySdk; /// 支付宝小游戏平台实现 /// 参考:https://opendocs.alipay.com/mini-game/ /// -internal class AlipayPlatform : IWebGamePlatform +internal class AlipayPlatform : IWebPlatformStrategy { /// - public UnityWebRequest CreateAssetBundleRequest(string url) + public UnityWebRequest CreateAssetBundleRequest(WebAssetBundleRequestArgs args) { - return APAssetBundle.GetAssetBundle(url); + UnityWebRequest request = APAssetBundle.GetAssetBundle(args.Url); + request.disposeDownloadHandlerOnDispose = true; + return request; } /// diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouFileSystem.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouFileSystem.cs index ba2768a0..7e2b7c76 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouFileSystem.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouFileSystem.cs @@ -3,41 +3,30 @@ using YooAsset; public static class KuaiShouFileSystemCreater { - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService) { - string fileSystemClass = $"{nameof(KuaiShouFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) { - string fileSystemClass = $"{nameof(KuaiShouFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) { - string fileSystemClass = $"{nameof(KuaiShouFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); return fileSystemParams; } -} -/// -/// 快手小游戏文件系统 -/// -internal class KuaiShouFileSystem : WebGameFileSystem -{ - /// - protected override IWebGamePlatform CreatePlatform(string packageRoot) + private static FileSystemParameters CreateBaseFileSystemParameters(IRemoteService remoteService) { - return new KuaiShouPlatform(); + var fileSystemParams = FileSystemParameters.CreateDefaultWebNetworkFileSystemParameters(remoteService, true); + fileSystemParams.AddParameter(EFileSystemParameter.WebPlatformStrategy, new KuaiShouPlatform()); + return fileSystemParams; } } #endif diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouPlatform.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouPlatform.cs index b38f6970..016a4dd1 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouPlatform.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/KuaiShouPlatform.cs @@ -7,12 +7,14 @@ using KSWASM; /// /// 快手小游戏平台实现 /// -internal class KuaiShouPlatform : IWebGamePlatform +internal class KuaiShouPlatform : IWebPlatformStrategy { /// - public UnityWebRequest CreateAssetBundleRequest(string url) + public UnityWebRequest CreateAssetBundleRequest(WebAssetBundleRequestArgs args) { - return KSAssetBundle.GetAssetBundle(url); + UnityWebRequest request = KSAssetBundle.GetAssetBundle(args.Url); + request.disposeDownloadHandlerOnDispose = true; + return request; } /// diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/README.md b/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/README.md index f7b161be..6f419376 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/README.md +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/KuaiShouFileSystem/README.md @@ -26,17 +26,16 @@ var createParameters = new WebPlayModeOptions(); string defaultHostServer = GetHostServerURL(); string fallbackHostServer = GetHostServerURL(); -string packageRoot = "/__GAME_FILE_CACHE"; IRemoteService remoteService = new RemoteService(defaultHostServer, fallbackHostServer); createParameters.WebServerFileSystemParameters = - KuaiShouFileSystemCreater.CreateFileSystemParameters(packageRoot, remoteService); + KuaiShouFileSystemCreater.CreateFileSystemParameters(remoteService); var initializationOperation = package.InitializePackageAsync(createParameters); #endif ``` -对当前文件系统来说,`packageRoot` 只需要是一个非空值。快手小游戏底层会对远程 AssetBundle 请求做平台适配,业务侧仍然按照远程异步加载流程使用 YooAsset。 +快手小游戏底层会对远程 AssetBundle 请求做平台适配,业务侧仍然按照远程异步加载流程使用 YooAsset。 ## 资源包命名 diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoFileSystem.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoFileSystem.cs index b7310190..e90c78b2 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoFileSystem.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoFileSystem.cs @@ -3,41 +3,30 @@ using YooAsset; public static class OppoFileSystemCreater { - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService) { - string fileSystemClass = $"{nameof(OppoFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) { - string fileSystemClass = $"{nameof(OppoFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) { - string fileSystemClass = $"{nameof(OppoFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); return fileSystemParams; } -} -/// -/// OPPO 小游戏文件系统 -/// -internal class OppoFileSystem : WebGameFileSystem -{ - /// - protected override IWebGamePlatform CreatePlatform(string packageRoot) + private static FileSystemParameters CreateBaseFileSystemParameters(IRemoteService remoteService) { - return new OppoPlatform(); + var fileSystemParams = FileSystemParameters.CreateDefaultWebNetworkFileSystemParameters(remoteService, true); + fileSystemParams.AddParameter(EFileSystemParameter.WebPlatformStrategy, new OppoPlatform()); + return fileSystemParams; } } #endif diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoPlatform.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoPlatform.cs index bd8aa2bc..8245fa3b 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoPlatform.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/OppoPlatform.cs @@ -6,12 +6,14 @@ using YooAsset; /// /// OPPO 小游戏平台实现 /// -internal class OppoPlatform : IWebGamePlatform +internal class OppoPlatform : IWebPlatformStrategy { /// - public UnityWebRequest CreateAssetBundleRequest(string url) + public UnityWebRequest CreateAssetBundleRequest(WebAssetBundleRequestArgs args) { - return UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(url); + UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(args.Url); + request.disposeDownloadHandlerOnDispose = true; + return request; } /// diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/README.md b/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/README.md index 9ea3d5d8..adc616b9 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/README.md +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/OppoFileSystem/README.md @@ -24,17 +24,16 @@ var createParameters = new WebPlayModeOptions(); string defaultHostServer = GetHostServerURL(); string fallbackHostServer = GetHostServerURL(); -string packageRoot = "/__GAME_FILE_CACHE"; IRemoteService remoteService = new RemoteService(defaultHostServer, fallbackHostServer); createParameters.WebServerFileSystemParameters = - OppoFileSystemCreater.CreateFileSystemParameters(packageRoot, remoteService); + OppoFileSystemCreater.CreateFileSystemParameters(remoteService); var initializationOperation = package.InitializePackageAsync(createParameters); #endif ``` -对当前文件系统来说,`packageRoot` 只需要是一个非空值。OPPO 真正的 AssetBundle 缓存行为由生成后小游戏工程里的 `manifest.json` 控制。 +OPPO 真正的 AssetBundle 缓存行为由生成后小游戏工程里的 `manifest.json` 控制。 ## OPPO 缓存配置 diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapFileSystem.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapFileSystem.cs index e1019beb..733aecd1 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapFileSystem.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapFileSystem.cs @@ -4,40 +4,30 @@ using TapTapMiniGame; public static class TaptapFileSystemCreater { - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService) { - string fileSystemClass = $"{nameof(TaptapFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) { - string fileSystemClass = $"{nameof(TaptapFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) { - string fileSystemClass = $"{nameof(TaptapFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); return fileSystemParams; } -} -/// -/// TapTap小游戏文件系统 -/// -internal class TaptapFileSystem : WebGameFileSystem -{ - protected override IWebGamePlatform CreatePlatform(string packageRoot) + private static FileSystemParameters CreateBaseFileSystemParameters(IRemoteService remoteService) { - return new TaptapPlatform(); + var fileSystemParams = FileSystemParameters.CreateDefaultWebNetworkFileSystemParameters(remoteService, true); + fileSystemParams.AddParameter(EFileSystemParameter.WebPlatformStrategy, new TaptapPlatform()); + return fileSystemParams; } } #endif diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapPlatform.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapPlatform.cs index 5becc395..440a83d1 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapPlatform.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapPlatform.cs @@ -8,12 +8,14 @@ using TapTapMiniGame; /// TapTap 小游戏平台实现 /// 参考:https://developer.taptap.cn/minigameapidoc/dev/engine/unity-adaptation/guide/ /// -internal class TaptapPlatform : IWebGamePlatform +internal class TaptapPlatform : IWebPlatformStrategy { /// - public UnityWebRequest CreateAssetBundleRequest(string url) + public UnityWebRequest CreateAssetBundleRequest(WebAssetBundleRequestArgs args) { - return TapAssetBundle.GetAssetBundle(url); + UnityWebRequest request = TapAssetBundle.GetAssetBundle(args.Url); + request.disposeDownloadHandlerOnDispose = true; + return request; } /// diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokFileSystem.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokFileSystem.cs index 8eaf6624..27496122 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokFileSystem.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokFileSystem.cs @@ -3,41 +3,30 @@ using YooAsset; public static class TiktokFileSystemCreater { - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService) { - string fileSystemClass = $"{nameof(TiktokFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) { - string fileSystemClass = $"{nameof(TiktokFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) { - string fileSystemClass = $"{nameof(TiktokFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); return fileSystemParams; } -} -/// -/// 抖音小游戏文件系统 -/// -internal class TiktokFileSystem : WebGameFileSystem -{ - /// - protected override IWebGamePlatform CreatePlatform(string packageRoot) + private static FileSystemParameters CreateBaseFileSystemParameters(IRemoteService remoteService) { - return new TiktokPlatform(); + var fileSystemParams = FileSystemParameters.CreateDefaultWebNetworkFileSystemParameters(remoteService, true); + fileSystemParams.AddParameter(EFileSystemParameter.WebPlatformStrategy, new TiktokPlatform()); + return fileSystemParams; } } #endif diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokPlatform.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokPlatform.cs index ee7434a4..c211cc9a 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokPlatform.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokPlatform.cs @@ -7,12 +7,14 @@ using TTSDK; /// /// 抖音小游戏平台实现 /// -internal class TiktokPlatform : IWebGamePlatform +internal class TiktokPlatform : IWebPlatformStrategy { /// - public UnityWebRequest CreateAssetBundleRequest(string url) + public UnityWebRequest CreateAssetBundleRequest(WebAssetBundleRequestArgs args) { - return TTAssetBundle.GetAssetBundle(url); + UnityWebRequest request = TTAssetBundle.GetAssetBundle(args.Url); + request.disposeDownloadHandlerOnDispose = true; + return request; } /// diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/README.md b/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/README.md index e543d11a..6079ac2e 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/README.md +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/README.md @@ -24,17 +24,16 @@ var createParameters = new WebPlayModeOptions(); string defaultHostServer = GetHostServerURL(); string fallbackHostServer = GetHostServerURL(); -string packageRoot = "/__GAME_FILE_CACHE"; IRemoteService remoteService = new RemoteService(defaultHostServer, fallbackHostServer); createParameters.WebServerFileSystemParameters = - VivoFileSystemCreater.CreateFileSystemParameters(packageRoot, remoteService); + VivoFileSystemCreater.CreateFileSystemParameters(remoteService); var initializationOperation = package.InitializePackageAsync(createParameters); #endif ``` -对当前文件系统来说,`packageRoot` 只需要是一个非空值。vivo 小游戏底层会对远程 AssetBundle 请求做缓存,业务侧仍然按照远程异步加载流程使用 YooAsset。 +vivo 小游戏底层会对远程 AssetBundle 请求做缓存,业务侧仍然按照远程异步加载流程使用 YooAsset。 ## 资源包命名 diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoFileSystem.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoFileSystem.cs index 55a5e18d..46db6138 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoFileSystem.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoFileSystem.cs @@ -3,41 +3,30 @@ using YooAsset; public static class VivoFileSystemCreater { - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService) { - string fileSystemClass = $"{nameof(VivoFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) { - string fileSystemClass = $"{nameof(VivoFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); return fileSystemParams; } - public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) { - string fileSystemClass = $"{nameof(VivoFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateBaseFileSystemParameters(remoteService); fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); return fileSystemParams; } -} -/// -/// vivo 小游戏文件系统 -/// -internal class VivoFileSystem : WebGameFileSystem -{ - /// - protected override IWebGamePlatform CreatePlatform(string packageRoot) + private static FileSystemParameters CreateBaseFileSystemParameters(IRemoteService remoteService) { - return new VivoPlatform(); + var fileSystemParams = FileSystemParameters.CreateDefaultWebNetworkFileSystemParameters(remoteService, true); + fileSystemParams.AddParameter(EFileSystemParameter.WebPlatformStrategy, new VivoPlatform()); + return fileSystemParams; } } #endif diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoPlatform.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoPlatform.cs index 1b1e9f69..dbe96dc5 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoPlatform.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/VivoFileSystem/VivoPlatform.cs @@ -6,12 +6,14 @@ using YooAsset; /// /// vivo 小游戏平台实现 /// -internal class VivoPlatform : IWebGamePlatform +internal class VivoPlatform : IWebPlatformStrategy { /// - public UnityWebRequest CreateAssetBundleRequest(string url) + public UnityWebRequest CreateAssetBundleRequest(WebAssetBundleRequestArgs args) { - return UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(url); + UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(args.Url); + request.disposeDownloadHandlerOnDispose = true; + return request; } /// diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatFileSystem.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatFileSystem.cs index 3ec830a4..467ce14f 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatFileSystem.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatFileSystem.cs @@ -4,19 +4,31 @@ using WeChatWASM; public static class WechatFileSystemCreater { + private static string DefaultWXCacheRoot => $"{WX.env.USER_DATA_PATH}/__GAME_FILE_CACHE"; + + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService) + { + var fileSystemParams = CreateFileSystemParameters(DefaultWXCacheRoot, remoteService, null, null); + return fileSystemParams; + } + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) + { + var fileSystemParams = CreateFileSystemParameters(DefaultWXCacheRoot, remoteService, assetBundleDecryptor, null); + return fileSystemParams; + } + public static FileSystemParameters CreateFileSystemParameters(IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) + { + var fileSystemParams = CreateFileSystemParameters(DefaultWXCacheRoot, remoteService, assetBundleDecryptor, rawBundleDecryptor); + return fileSystemParams; + } public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService) { - string fileSystemClass = $"{nameof(WechatFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); + var fileSystemParams = CreateFileSystemParameters(packageRoot, remoteService, null, null); return fileSystemParams; } public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor) { - string fileSystemClass = $"{nameof(WechatFileSystem)},YooAsset.MiniGame"; - var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); - fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); - fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); + var fileSystemParams = CreateFileSystemParameters(packageRoot, remoteService, assetBundleDecryptor, null); return fileSystemParams; } public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteService remoteService, IBundleDecryptor assetBundleDecryptor, IBundleDecryptor rawBundleDecryptor) @@ -24,8 +36,13 @@ public static class WechatFileSystemCreater string fileSystemClass = $"{nameof(WechatFileSystem)},YooAsset.MiniGame"; var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); fileSystemParams.AddParameter(EFileSystemParameter.RemoteService, remoteService); - fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); - fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); + fileSystemParams.AddParameter(EFileSystemParameter.DisableUnityWebCache, true); + fileSystemParams.AddParameter(EFileSystemParameter.WebPlatformStrategy, new WechatPlatform()); + + if (assetBundleDecryptor != null) + fileSystemParams.AddParameter(EFileSystemParameter.AssetbundleDecryptor, assetBundleDecryptor); + if (rawBundleDecryptor != null) + fileSystemParams.AddParameter(EFileSystemParameter.RawbundleDecryptor, rawBundleDecryptor); return fileSystemParams; } } @@ -33,10 +50,9 @@ public static class WechatFileSystemCreater /// /// 微信小游戏文件系统 /// -internal class WechatFileSystem : WebGameFileSystem +internal class WechatFileSystem : WebNetworkFileSystem { private string _wxCacheRoot; - private WechatPlatform _wechatPlatform; /// public override FSClearCacheOperation ClearCacheAsync(FSClearCacheOptions options) @@ -60,11 +76,10 @@ internal class WechatFileSystem : WebGameFileSystem } /// - protected override IWebGamePlatform CreatePlatform(string packageRoot) + public override void OnCreate(string packageName, string packageRoot) { _wxCacheRoot = packageRoot; - _wechatPlatform = new WechatPlatform(); - return _wechatPlatform; + base.OnCreate(packageName, packageRoot); } internal string GetWXCacheRoot() diff --git a/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatPlatform.cs b/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatPlatform.cs index 79322ca3..00476dcb 100644 --- a/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatPlatform.cs +++ b/Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatPlatform.cs @@ -7,12 +7,14 @@ using WeChatWASM; /// /// 微信小游戏平台实现 /// -internal class WechatPlatform : IWebGamePlatform +internal class WechatPlatform : IWebPlatformStrategy { /// - public UnityWebRequest CreateAssetBundleRequest(string url) + public UnityWebRequest CreateAssetBundleRequest(WebAssetBundleRequestArgs args) { - return WXAssetBundle.GetAssetBundle(url); + UnityWebRequest request = WXAssetBundle.GetAssetBundle(args.Url); + request.disposeDownloadHandlerOnDispose = true; + return request; } ///