diff --git a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs
index 2d6925e..8776582 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs
@@ -195,6 +195,7 @@ namespace YooAsset
// 3. 检测APK拷贝文件结果
if (_steps == ESteps.CheckDownloadFromApk)
{
+ Progress = _fileRequester.Progress();
if (_fileRequester.IsDone() == false)
return;
@@ -336,6 +337,7 @@ namespace YooAsset
// 3. 检测服务器下载结果
if (_steps == ESteps.CheckDownloadFromWeb)
{
+ Progress = _downloader.DownloadProgress;
if (_downloader.IsDone() == false)
return;
@@ -363,6 +365,7 @@ namespace YooAsset
// 5. 检测APK拷贝文件结果
if (_steps == ESteps.CheckDownloadFromApk)
{
+ Progress = _fileRequester.Progress();
if (_fileRequester.IsDone() == false)
return;
diff --git a/Assets/YooAsset/Runtime/AssetSystem/Operations/UnloadSceneOperation.cs b/Assets/YooAsset/Runtime/AssetSystem/Operations/UnloadSceneOperation.cs
index 12ba3d3..272382d 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Operations/UnloadSceneOperation.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Operations/UnloadSceneOperation.cs
@@ -26,19 +26,6 @@ namespace YooAsset
private Scene _scene;
private AsyncOperation _asyncOp;
- ///
- /// 场景卸载进度
- ///
- public float Progress
- {
- get
- {
- if (_asyncOp == null)
- return 0;
- return _asyncOp.progress;
- }
- }
-
internal UnloadSceneOperation(string error)
{
_flag = EFlag.Error;
@@ -87,6 +74,7 @@ namespace YooAsset
if (_steps == ESteps.Checking)
{
+ Progress = _asyncOp.progress;
if (_asyncOp.isDone == false)
return;
diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs
index 29fdbbd..6cb6207 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs
@@ -11,7 +11,7 @@ namespace YooAsset
get
{
if (IsDone)
- return 100f;
+ return 1f;
else
return 0;
}
diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs
index a633835..ad9b982 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs
@@ -11,7 +11,7 @@ namespace YooAsset
get
{
if (IsDone)
- return 100f;
+ return 1f;
else
return 0;
}
diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs
index 1011134..0f776ff 100644
--- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs
+++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs
@@ -28,7 +28,7 @@ namespace YooAsset
///
- /// 下载进度(0-100f)
+ /// 下载进度
///
public float DownloadProgress
{
diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs
index 55ef042..74c4fc0 100644
--- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs
+++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs
@@ -53,7 +53,7 @@ namespace YooAsset
// 检测下载结果
if (_steps == ESteps.CheckDownload)
{
- _downloadProgress = _webRequest.downloadProgress * 100f;
+ _downloadProgress = _webRequest.downloadProgress;
_downloadedBytes = _webRequest.downloadedBytes;
if (_operationHandle.isDone == false)
{
diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs
index 73a2cb4..69401a9 100644
--- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs
+++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs
@@ -203,7 +203,7 @@ namespace YooAsset
if (_steps == ESteps.CheckDownload)
{
- _downloadProgress = _threadDownloader.DownloadProgress * 100f;
+ _downloadProgress = _threadDownloader.DownloadProgress;
_downloadedBytes = _threadDownloader.DownloadedBytes;
if (_threadDownloader.IsDone == false)
return;
diff --git a/Assets/YooAsset/Runtime/DownloadSystem/UnityWebDataRequester.cs b/Assets/YooAsset/Runtime/DownloadSystem/UnityWebDataRequester.cs
index 9424ef9..5eca183 100644
--- a/Assets/YooAsset/Runtime/DownloadSystem/UnityWebDataRequester.cs
+++ b/Assets/YooAsset/Runtime/DownloadSystem/UnityWebDataRequester.cs
@@ -83,6 +83,16 @@ namespace YooAsset
return _operationHandle.isDone;
}
+ ///
+ /// 下载进度
+ ///
+ public float Progress()
+ {
+ if (_operationHandle == null)
+ return 0;
+ return _operationHandle.progress;
+ }
+
///
/// 下载是否发生错误
///
diff --git a/Assets/YooAsset/Runtime/DownloadSystem/UnityWebFileRequester.cs b/Assets/YooAsset/Runtime/DownloadSystem/UnityWebFileRequester.cs
index 9ce83e2..eccdfe6 100644
--- a/Assets/YooAsset/Runtime/DownloadSystem/UnityWebFileRequester.cs
+++ b/Assets/YooAsset/Runtime/DownloadSystem/UnityWebFileRequester.cs
@@ -60,6 +60,16 @@ namespace YooAsset
return _operationHandle.isDone;
}
+ ///
+ /// 下载进度
+ ///
+ public float Progress()
+ {
+ if (_operationHandle == null)
+ return 0;
+ return _operationHandle.progress;
+ }
+
///
/// 下载是否发生错误
///
diff --git a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
index 9af6f04..f2cbed6 100644
--- a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
+++ b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
@@ -18,7 +18,12 @@ namespace YooAsset
///
/// 错误信息
///
- public string Error { get; protected set; } = string.Empty;
+ public string Error { get; protected set; }
+
+ ///
+ /// 处理进度
+ ///
+ public float Progress { get; protected set; }
///
/// 是否已经完成
@@ -70,8 +75,8 @@ namespace YooAsset
internal abstract void Update();
internal void Finish()
{
+ Progress = 1f;
_callback?.Invoke(this);
-
if (_taskCompletionSource != null)
_taskCompletionSource.TrySetResult(null);
}
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs
index ddf6135..1e01f08 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs
@@ -145,6 +145,7 @@ namespace YooAsset
{
_lastDownloadBytes = downloadBytes;
_lastDownloadCount = CurrentDownloadCount;
+ Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
}
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs
index a7123f1..ebf7578 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs
@@ -108,6 +108,7 @@ namespace YooAsset
if (_steps == ESteps.Update)
{
_appManifestLoader.Update();
+ Progress = _appManifestLoader.Progress();
if (_appManifestLoader.IsDone() == false)
return;
@@ -181,6 +182,7 @@ namespace YooAsset
if (_steps == ESteps.Update)
{
_appManifestLoader.Update();
+ Progress = _appManifestLoader.Progress();
if (_appManifestLoader.IsDone() == false)
return;
@@ -243,6 +245,16 @@ namespace YooAsset
return false;
}
+ ///
+ /// 加载进度
+ ///
+ public float Progress()
+ {
+ if (_downloader2 == null)
+ return 0;
+ return _downloader2.Progress();
+ }
+
public void Update()
{
if (IsDone())
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs
index 9516fb0..6367c59 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs
@@ -172,6 +172,7 @@ namespace YooAsset
if (_steps == ESteps.UpdateVerifyingCache)
{
+ Progress = GetVerifyProgress();
if (UpdateVerifyingCache())
{
_steps = ESteps.Done;
@@ -258,6 +259,7 @@ namespace YooAsset
private readonly List _verifyingList = new List(100);
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
private int _verifyMaxNum = 32;
+ private int _verifyTotalCount = 0;
private int _verifySuccessCount = 0;
private int _verifyFailCount = 0;
@@ -290,6 +292,7 @@ namespace YooAsset
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
+ _verifyTotalCount = _waitingList.Count;
}
private bool UpdateVerifyingCache()
{
@@ -358,6 +361,12 @@ namespace YooAsset
}
_verifyingList.Remove(info.Bundle);
}
+ private float GetVerifyProgress()
+ {
+ if (_verifyTotalCount == 0)
+ return 1f;
+ return (float)(_verifySuccessCount + _verifyFailCount) / _verifyTotalCount;
+ }
#endregion
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs
index 89dd3c5..d8dda31 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs
@@ -111,6 +111,7 @@ namespace YooAsset
if (_steps == ESteps.CheckWebManifest)
{
+ Progress = _downloaderManifest.Progress();
if (_downloaderManifest.IsDone() == false)
return;
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs
index 62a5b4c..449e01b 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs
@@ -87,6 +87,7 @@ namespace YooAsset
if (_steps == ESteps.CheckStaticVersion)
{
+ Progress = _downloader.Progress();
if (_downloader.IsDone() == false)
return;
@@ -105,7 +106,7 @@ namespace YooAsset
Status = EOperationStatus.Succeed;
}
else
- {
+ {
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"URL : {_downloader.URL} Error : static version content is invalid.";