From e9841a65c60bffd08cda7e1143511744997f8ad4 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sat, 21 May 2022 22:36:06 +0800 Subject: [PATCH] Added pause method and resume method to patch downloader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补丁下载器增加暂停方法和恢复方法 --- .../Operations/DownloaderOperation.cs | 20 +++++++++++++++++++ .../Runtime/PatchSystem/PatchManifest.cs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs index 6615234..4e57fed 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs @@ -28,6 +28,7 @@ namespace YooAsset // 数据相关 private ESteps _steps = ESteps.None; + private bool _isPause = false; private long _lastDownloadBytes = 0; private int _lastDownloadCount = 0; @@ -153,6 +154,9 @@ namespace YooAsset // 注意:如果期间有下载失败的文件,暂停动态创建下载器 if (_downloadList.Count > 0 && _loadFailedList.Count == 0) { + if (_isPause) + return; + if (_downloaders.Count < _downloadingMaxNumber) { int index = _downloadList.Count - 1; @@ -195,6 +199,22 @@ namespace YooAsset OperationSystem.StartOperaiton(this); } } + + /// + /// 暂停下载 + /// + public void PauseDownload() + { + _isPause = true; + } + + /// + /// 恢复下载 + /// + public void ResumeDownload() + { + _isPause = false; + } } public sealed class PackageDownloaderOperation : DownloaderOperation diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs index fce87cf..d5b10aa 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs @@ -23,7 +23,7 @@ namespace YooAsset public int ResourceVersion; /// - /// 内置资源的标记列表 + /// 内置资源的标签列表(首包资源) /// public string BuildinTags;