Compare commits

..

No commits in common. "c0d42e79d81752b42de06aab0b0a4c48177979c3" and "9fb7f8bbfe0ac22d29603e54564e98a4d014e7b0" have entirely different histories.

33 changed files with 144 additions and 154 deletions

View File

@ -0,0 +1,30 @@

namespace YooAsset
{
internal class DownloadParam
{
public readonly int FailedTryAgain;
public readonly int Timeout;
/// <summary>
/// 导入的本地文件路径
/// </summary>
public string ImportFilePath { set; get; }
/// <summary>
/// 主资源地址
/// </summary>
public string MainURL { set; get; }
/// <summary>
/// 备用资源地址
/// </summary>
public string FallbackURL { set; get; }
public DownloadParam(int failedTryAgain, int timeout)
{
FailedTryAgain = failedTryAgain;
Timeout = timeout;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56ea224b45d314e4a86b558404e9b6c8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -109,15 +109,15 @@ namespace YooAsset
var operation = new DBFSRequestPackageVersionOperation(this); var operation = new DBFSRequestPackageVersionOperation(this);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
{ {
return _unpackFileSystem.ClearCacheFilesAsync(manifest, options); return _unpackFileSystem.ClearCacheFilesAsync(manifest, clearMode, clearParam);
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
// 注意:业务层的解压下载器会依赖内置文件系统的下载方法 // 注意:业务层的解压下载器会依赖内置文件系统的下载方法
options.ImportFilePath = GetBuildinFileLoadPath(bundle); param.ImportFilePath = GetBuildinFileLoadPath(bundle);
return _unpackFileSystem.DownloadFileAsync(bundle, options); return _unpackFileSystem.DownloadFileAsync(bundle, param);
} }
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{ {

View File

@ -120,43 +120,43 @@ namespace YooAsset
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout); var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
{ {
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString()) if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
{ {
var operation = new ClearAllCacheBundleFilesOperation(this); var operation = new ClearAllCacheBundleFilesOperation(this);
return operation; return operation;
} }
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString()) else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
{ {
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest); var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
return operation; return operation;
} }
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByTags.ToString()) else if (clearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
{ {
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, options.ClearParam); var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, clearParam);
return operation; return operation;
} }
else if (options.ClearMode == EFileClearMode.ClearAllManifestFiles.ToString()) else if (clearMode == EFileClearMode.ClearAllManifestFiles.ToString())
{ {
var operation = new ClearAllCacheManifestFilesOperation(this); var operation = new ClearAllCacheManifestFilesOperation(this);
return operation; return operation;
} }
else if (options.ClearMode == EFileClearMode.ClearUnusedManifestFiles.ToString()) else if (clearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
{ {
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest); var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
return operation; return operation;
} }
else else
{ {
string error = $"Invalid clear mode : {options.ClearMode}"; string error = $"Invalid clear mode : {clearMode}";
var operation = new FSClearCacheFilesCompleteOperation(error); var operation = new FSClearCacheFilesCompleteOperation(error);
return operation; return operation;
} }
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
var downloader = DownloadCenter.DownloadFileAsync(bundle, options); var downloader = DownloadCenter.DownloadFileAsync(bundle, param);
downloader.Reference(); //增加下载器的引用计数 downloader.Reference(); //增加下载器的引用计数
// 注意:将下载器进行包裹,可以避免父类任务终止的时候,连带子任务里的下载器也一起被终止! // 注意:将下载器进行包裹,可以避免父类任务终止的时候,连带子任务里的下载器也一起被终止!

View File

@ -58,8 +58,8 @@ namespace YooAsset
// 注意边玩边下下载器引用计数没有Release // 注意边玩边下下载器引用计数没有Release
if (_downloadFileOp == null) if (_downloadFileOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options); _downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
_downloadFileOp.StartOperation(); _downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp); AddChildOperation(_downloadFileOp);
} }
@ -297,8 +297,8 @@ namespace YooAsset
// 注意边玩边下下载器引用计数没有Release // 注意边玩边下下载器引用计数没有Release
if (_downloadFileOp == null) if (_downloadFileOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options); _downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
_downloadFileOp.StartOperation(); _downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp); AddChildOperation(_downloadFileOp);
} }

View File

@ -74,7 +74,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 创建下载任务 /// 创建下载任务
/// </summary> /// </summary>
public FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
// 查询旧的下载器 // 查询旧的下载器
if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader)) if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader))
@ -83,29 +83,29 @@ namespace YooAsset
} }
// 设置请求URL // 设置请求URL
if (string.IsNullOrEmpty(options.ImportFilePath)) if (string.IsNullOrEmpty(param.ImportFilePath))
{ {
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(bundle.FileName); param.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(bundle.FileName);
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(bundle.FileName); param.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(bundle.FileName);
} }
else else
{ {
// 注意:把本地文件路径指定为远端下载地址 // 注意:把本地文件路径指定为远端下载地址
options.MainURL = DownloadSystemHelper.ConvertToWWWPath(options.ImportFilePath); param.MainURL = DownloadSystemHelper.ConvertToWWWPath(param.ImportFilePath);
options.FallbackURL = options.MainURL; param.FallbackURL = param.MainURL;
} }
// 创建新的下载器 // 创建新的下载器
DefaultDownloadFileOperation newDownloader; DefaultDownloadFileOperation newDownloader;
if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize) if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize)
{ {
newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, options); newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, param);
AddChildOperation(newDownloader); AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader); _downloaders.Add(bundle.BundleGUID, newDownloader);
} }
else else
{ {
newDownloader = new DownloadNormalFileOperation(_fileSystem, bundle, options); newDownloader = new DownloadNormalFileOperation(_fileSystem, bundle, param);
AddChildOperation(newDownloader); AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader); _downloaders.Add(bundle.BundleGUID, newDownloader);
} }

View File

@ -12,13 +12,13 @@ namespace YooAsset
private string _tempFilePath; private string _tempFilePath;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal DownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Options.MainURL); _isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
_tempFilePath = _fileSystem.GetTempFilePath(Bundle); _tempFilePath = _fileSystem.GetTempFilePath(Bundle);
_steps = ESteps.CheckExists; _steps = ESteps.CheckExists;
} }

View File

@ -15,13 +15,13 @@ namespace YooAsset
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal DownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Options.MainURL); _isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
_tempFilePath = _fileSystem.GetTempFilePath(Bundle); _tempFilePath = _fileSystem.GetTempFilePath(Bundle);
_steps = ESteps.CheckExists; _steps = ESteps.CheckExists;
} }

View File

@ -66,12 +66,12 @@ namespace YooAsset
var operation = new DEFSRequestPackageVersionOperation(this); var operation = new DEFSRequestPackageVersionOperation(this);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
{ {
var operation = new FSClearCacheFilesCompleteOperation(); var operation = new FSClearCacheFilesCompleteOperation();
return operation; return operation;
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }

View File

@ -73,12 +73,12 @@ namespace YooAsset
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout); var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
{ {
var operation = new FSClearCacheFilesCompleteOperation(); var operation = new FSClearCacheFilesCompleteOperation();
return operation; return operation;
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }

View File

@ -34,19 +34,19 @@ namespace YooAsset
{ {
if (_downloadAssetBundleOp == null) if (_downloadAssetBundleOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName); downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
if (_bundle.Encrypted) if (_bundle.Encrypted)
{ {
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, options); _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }
else else
{ {
_downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, options); _downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }

View File

@ -82,12 +82,12 @@ namespace YooAsset
var operation = new DWSFSRequestPackageVersionOperation(this, timeout); var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
{ {
var operation = new FSClearCacheFilesCompleteOperation(); var operation = new FSClearCacheFilesCompleteOperation();
return operation; return operation;
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }

View File

@ -34,20 +34,20 @@ namespace YooAsset
{ {
if (_downloadAssetBundleOp == null) if (_downloadAssetBundleOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle); string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
options.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath); downloadParam.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
options.FallbackURL = options.MainURL; downloadParam.FallbackURL = downloadParam.MainURL;
if (_bundle.Encrypted) if (_bundle.Encrypted)
{ {
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, options); _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }
else else
{ {
_downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, options); _downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }

View File

@ -37,12 +37,12 @@ namespace YooAsset
/// <summary> /// <summary>
/// 清理缓存文件 /// 清理缓存文件
/// </summary> /// </summary>
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options); FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam);
/// <summary> /// <summary>
/// 下载Bundle文件 /// 下载Bundle文件
/// </summary> /// </summary>
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options); FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param);
/// <summary> /// <summary>
/// 加载Bundle文件 /// 加载Bundle文件

View File

@ -1,19 +1,6 @@
 
namespace YooAsset namespace YooAsset
{ {
internal class ClearCacheFilesOptions
{
/// <summary>
/// 清理模式
/// </summary>
public string ClearMode;
/// <summary>
/// 附加参数
/// </summary>
public object ClearParam;
}
internal abstract class FSClearCacheFilesOperation : AsyncOperationBase internal abstract class FSClearCacheFilesOperation : AsyncOperationBase
{ {
} }

View File

@ -1,40 +1,6 @@
 
namespace YooAsset namespace YooAsset
{ {
internal class DownloadFileOptions
{
/// <summary>
/// 失败后重试次数
/// </summary>
public readonly int FailedTryAgain;
/// <summary>
/// 超时时间
/// </summary>
public readonly int Timeout;
/// <summary>
/// 主资源地址
/// </summary>
public string MainURL { set; get; }
/// <summary>
/// 备用资源地址
/// </summary>
public string FallbackURL { set; get; }
/// <summary>
/// 导入的本地文件路径
/// </summary>
public string ImportFilePath { set; get; }
public DownloadFileOptions(int failedTryAgain, int timeout)
{
FailedTryAgain = failedTryAgain;
Timeout = timeout;
}
}
internal abstract class FSDownloadFileOperation : AsyncOperationBase internal abstract class FSDownloadFileOperation : AsyncOperationBase
{ {
public PackageBundle Bundle { private set; get; } public PackageBundle Bundle { private set; get; }

View File

@ -18,7 +18,7 @@ namespace YooAsset
} }
// 下载参数 // 下载参数
protected readonly DownloadFileOptions Options; protected readonly DownloadParam Param;
// 请求相关 // 请求相关
protected UnityWebRequest _webRequest; protected UnityWebRequest _webRequest;
@ -35,10 +35,10 @@ namespace YooAsset
protected int FailedTryAgain; protected int FailedTryAgain;
internal DefaultDownloadFileOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle) internal DefaultDownloadFileOperation(PackageBundle bundle, DownloadParam param) : base(bundle)
{ {
Options = options; Param = param;
FailedTryAgain = options.FailedTryAgain; FailedTryAgain = param.FailedTryAgain;
} }
/// <summary> /// <summary>
@ -49,9 +49,9 @@ namespace YooAsset
// 轮流返回请求地址 // 轮流返回请求地址
_requestCount++; _requestCount++;
if (_requestCount % 2 == 0) if (_requestCount % 2 == 0)
return Options.FallbackURL; return Param.FallbackURL;
else else
return Options.MainURL; return Param.MainURL;
} }
/// <summary> /// <summary>
@ -87,7 +87,7 @@ namespace YooAsset
} }
float offset = UnityEngine.Time.realtimeSinceStartup - _latestDownloadRealtime; float offset = UnityEngine.Time.realtimeSinceStartup - _latestDownloadRealtime;
if (offset > Options.Timeout) if (offset > Param.Timeout)
{ {
YooLogger.Warning($"Download request timeout : {_requestURL}"); YooLogger.Warning($"Download request timeout : {_requestURL}");
if (_webRequest != null) if (_webRequest != null)

View File

@ -4,7 +4,7 @@ namespace YooAsset
{ {
internal abstract class DownloadAssetBundleOperation : DefaultDownloadFileOperation internal abstract class DownloadAssetBundleOperation : DefaultDownloadFileOperation
{ {
internal DownloadAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal DownloadAssetBundleOperation(PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
} }

View File

@ -10,7 +10,7 @@ namespace YooAsset
private DownloadHandlerBuffer _downloadhandler; private DownloadHandlerBuffer _downloadhandler;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadWebEncryptAssetBundleOperation(bool checkTimeout, IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal DownloadWebEncryptAssetBundleOperation(bool checkTimeout, IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
_checkTimeout = checkTimeout; _checkTimeout = checkTimeout;
_decryptionServices = decryptionServices; _decryptionServices = decryptionServices;

View File

@ -9,7 +9,7 @@ namespace YooAsset
private DownloadHandlerAssetBundle _downloadhandler; private DownloadHandlerAssetBundle _downloadhandler;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadWebNormalAssetBundleOperation(bool disableUnityWebCache, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal DownloadWebNormalAssetBundleOperation(bool disableUnityWebCache, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
_disableUnityWebCache = disableUnityWebCache; _disableUnityWebCache = disableUnityWebCache;
} }

View File

@ -38,9 +38,9 @@ namespace YooAsset
/// </summary> /// </summary>
public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout) public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout)
{ {
DownloadFileOptions options = new DownloadFileOptions(failedTryAgain, timeout); DownloadParam downloadParam = new DownloadParam(failedTryAgain, timeout);
options.ImportFilePath = _importFilePath; downloadParam.ImportFilePath = _importFilePath;
return _fileSystem.DownloadFileAsync(Bundle, options); return _fileSystem.DownloadFileAsync(Bundle, downloadParam);
} }
/// <summary> /// <summary>

View File

@ -31,7 +31,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 清理缓存文件 /// 清理缓存文件
/// </summary> /// </summary>
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options); ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam);
// 下载相关 // 下载相关
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout); ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);

View File

@ -15,15 +15,17 @@ namespace YooAsset
} }
private readonly PlayModeImpl _impl; private readonly PlayModeImpl _impl;
private readonly ClearCacheFilesOptions _options; private readonly string _clearMode;
private readonly object _clearParam;
private List<IFileSystem> _cloneList; private List<IFileSystem> _cloneList;
private FSClearCacheFilesOperation _clearCacheFilesOp; private FSClearCacheFilesOperation _clearCacheFilesOp;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal ClearCacheFilesOperation(PlayModeImpl impl, ClearCacheFilesOptions options) internal ClearCacheFilesOperation(PlayModeImpl impl, string clearMode, object clearParam)
{ {
_impl = impl; _impl = impl;
_options = options; _clearMode = clearMode;
_clearParam = clearParam;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@ -72,7 +74,7 @@ namespace YooAsset
var fileSystem = _cloneList[0]; var fileSystem = _cloneList[0];
_cloneList.RemoveAt(0); _cloneList.RemoveAt(0);
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _options); _clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
_clearCacheFilesOp.StartOperation(); _clearCacheFilesOp.StartOperation();
AddChildOperation(_clearCacheFilesOp); AddChildOperation(_clearCacheFilesOp);
_steps = ESteps.CheckClearResult; _steps = ESteps.CheckClearResult;
@ -100,7 +102,7 @@ namespace YooAsset
} }
internal override string InternalGetDesc() internal override string InternalGetDesc()
{ {
return $"ClearMode : {_options.ClearMode}"; return $"ClearMode : {_clearMode}";
} }
} }
} }

View File

@ -97,9 +97,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 清理缓存文件 /// 清理缓存文件
/// </summary> /// </summary>
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(ClearCacheFilesOptions options) ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
{ {
var operation = new ClearCacheFilesOperation(this, options); var operation = new ClearCacheFilesOperation(this, clearMode, clearParam);
return operation; return operation;
} }

View File

@ -268,10 +268,7 @@ namespace YooAsset
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null) public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
{ {
DebugCheckInitialize(false); DebugCheckInitialize(false);
ClearCacheFilesOptions options = new ClearCacheFilesOptions(); var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
options.ClearMode = clearMode.ToString();
options.ClearParam = clearParam;
var operation = _playModeImpl.ClearCacheFilesAsync(options);
OperationSystem.StartOperation(PackageName, operation); OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
@ -284,10 +281,7 @@ namespace YooAsset
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null) public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
{ {
DebugCheckInitialize(false); DebugCheckInitialize(false);
ClearCacheFilesOptions options = new ClearCacheFilesOptions(); var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
options.ClearMode = clearMode;
options.ClearParam = clearParam;
var operation = _playModeImpl.ClearCacheFilesAsync(options);
OperationSystem.StartOperation(PackageName, operation); OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }

View File

@ -8,7 +8,7 @@ internal class TTFSDownloadFileOperation : DefaultDownloadFileOperation
private TiktokFileSystem _fileSystem; private TiktokFileSystem _fileSystem;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal TTFSDownloadFileOperation(TiktokFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal TTFSDownloadFileOperation(TiktokFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }

View File

@ -35,19 +35,19 @@ internal class TTFSLoadBundleOperation : FSLoadBundleOperation
{ {
if (_downloadAssetBundleOp == null) if (_downloadAssetBundleOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ; downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ;
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName); downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
if (_bundle.Encrypted) if (_bundle.Encrypted)
{ {
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, options); _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }
else else
{ {
_downloadAssetBundleOp = new DownloadTiktokAssetBundleOperation(_bundle, options); _downloadAssetBundleOp = new DownloadTiktokAssetBundleOperation(_bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }

View File

@ -8,7 +8,7 @@ namespace YooAsset
{ {
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadTiktokAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal DownloadTiktokAssetBundleOperation(PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
} }
internal override void InternalStart() internal override void InternalStart()

View File

@ -124,16 +124,16 @@ internal class TiktokFileSystem : IFileSystem
var operation = new TTFSRequestPackageVersionOperation(this, timeout); var operation = new TTFSRequestPackageVersionOperation(this, timeout);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
{ {
var operation = new FSClearCacheFilesCompleteOperation(); var operation = new FSClearCacheFilesCompleteOperation();
return operation; return operation;
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
options.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName); param.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
options.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName); param.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
var operation = new TTFSDownloadFileOperation(this, bundle, options); var operation = new TTFSDownloadFileOperation(this, bundle, param);
return operation; return operation;
} }
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)

View File

@ -9,7 +9,7 @@ internal class WXFSDownloadFileOperation : DefaultDownloadFileOperation
private WechatFileSystem _fileSystem; private WechatFileSystem _fileSystem;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal WXFSDownloadFileOperation(WechatFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal WXFSDownloadFileOperation(WechatFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }

View File

@ -33,19 +33,19 @@ internal class WXFSLoadBundleOperation : FSLoadBundleOperation
{ {
if (_downloadAssetBundleOp == null) if (_downloadAssetBundleOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ; downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ;
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName); downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
if (_bundle.Encrypted) if (_bundle.Encrypted)
{ {
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, options); _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }
else else
{ {
_downloadAssetBundleOp = new DownloadWechatAssetBundleOperation(_bundle, options); _downloadAssetBundleOp = new DownloadWechatAssetBundleOperation(_bundle, downloadParam);
_downloadAssetBundleOp.StartOperation(); _downloadAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_downloadAssetBundleOp);
} }

View File

@ -8,7 +8,7 @@ namespace YooAsset
{ {
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadWechatAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle, options) internal DownloadWechatAssetBundleOperation(PackageBundle bundle, DownloadParam param) : base(bundle, param)
{ {
} }
internal override void InternalStart() internal override void InternalStart()

View File

@ -125,30 +125,30 @@ internal class WechatFileSystem : IFileSystem
var operation = new WXFSRequestPackageVersionOperation(this, appendTimeTicks, timeout); var operation = new WXFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
{ {
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString()) if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
{ {
var operation = new WXFSClearAllBundleFilesOperation(this); var operation = new WXFSClearAllBundleFilesOperation(this);
return operation; return operation;
} }
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString()) else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
{ {
var operation = new WXFSClearUnusedBundleFilesAsync(this, manifest); var operation = new WXFSClearUnusedBundleFilesAsync(this, manifest);
return operation; return operation;
} }
else else
{ {
string error = $"Invalid clear mode : {options.ClearMode}"; string error = $"Invalid clear mode : {clearMode}";
var operation = new FSClearCacheFilesCompleteOperation(error); var operation = new FSClearCacheFilesCompleteOperation(error);
return operation; return operation;
} }
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
options.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName); param.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
options.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName); param.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
var operation = new WXFSDownloadFileOperation(this, bundle, options); var operation = new WXFSDownloadFileOperation(this, bundle, param);
return operation; return operation;
} }
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)