From c15651dcb716b18bf335eb3aa7edf4599782d604 Mon Sep 17 00:00:00 2001 From: Starfire-Corporation-Win <1398581458@qq.com> Date: Fri, 26 Jan 2024 15:15:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=92=AB=20=E4=BF=AE=E5=A4=8D=20-=20Tas?= =?UTF-8?q?k=E8=B5=84=E6=BA=90=E4=B8=8B=E8=BD=BD=E5=99=A8=20=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9B=B4=E6=96=B0=E4=BA=8B=E4=BB=B6=20=E7=99=BE?= =?UTF-8?q?=E5=88=86=E6=AF=94=E5=80=BC=E4=B8=BA200%=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=BA=20100%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/Event/Loading.cs | 2 +- .../Proxy.YooAsset/YAssetProxy.Downloader.cs | 34 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/Extensions/Event/Loading.cs b/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/Extensions/Event/Loading.cs index a70d67c..4ffe66c 100644 --- a/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/Extensions/Event/Loading.cs +++ b/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/Extensions/Event/Loading.cs @@ -222,7 +222,7 @@ private static async Task WaitTask(DownloaderOperation operation, AssetInfo loca break; } case NetworkReachability.ReachableViaLocalAreaNetwork: - break; + break; } if (AssetSystem.HandleReset) return; diff --git a/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/YAssetProxy.Downloader.cs b/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/YAssetProxy.Downloader.cs index a4fb6ca..e683c68 100644 --- a/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/YAssetProxy.Downloader.cs +++ b/Extensions/YooAsset.CLI/Runtime/1.5.7/Proxy.YooAsset/YAssetProxy.Downloader.cs @@ -225,7 +225,7 @@ public void CollectNeedAll() var operation = asset.CreateResourceDownloader(); if (operation is null) continue; if (operation.TotalDownloadCount <= 0) continue; - ResourceDownloaderOperations[string.Concat("ALL-", name)] = operation; + ResourceDownloaderOperations[string.Concat("ALL-", name, '-', DateTime.Now.Ticks)] = operation; } OpenDownloadAll = true; @@ -246,7 +246,6 @@ private void CollectNeedTagBegin(params string[] tags) if (tags is null || tags.Length == 0) return; foreach (var name in ManifestOperations.Keys) { - AssetSystem.Log($"CollectNeedTagBegin -> {name}"); if (!Packages.TryGetValue(name, out var asset)) continue; Tags[name] = 1; var operation = @@ -269,6 +268,9 @@ public void CollectNeedTag(params string[] tags) protected override async Task OnWaitAsync() { + CurrentValueDict.Clear(); + TotalValueDict.Clear(); + foreach (var pair in ResourceDownloaderOperations) { CurrentValueDict[pair.Key] = pair.Value.CurrentDownloadBytes; @@ -277,7 +279,7 @@ protected override async Task OnWaitAsync() TotalValue = TotalValueDict.Sum(pair => pair.Value); CurrentValue = CurrentValueDict.Sum(pair => pair.Value); - if (AssetSystem.GetAvailableDiskSpace() < TotalValue) // 检查磁盘空间是否足够 + if (AssetSystem.GetAvailableDiskSpace() < TotalValue - CurrentValue) // 检查磁盘空间是否足够 { State = EProgressState.Fail; if (OnDiskSpaceNotEnough is null) @@ -340,7 +342,9 @@ void OnUpdateProgress(int _, int __, long totalDownloadBytes, long currentDownlo break; } - CurrentValueDict[pair.Key] = pair.Value.CurrentDownloadBytes + currentDownloadBytes; + TotalValueDict[pair.Key] = totalDownloadBytes; + TotalValue = TotalValueDict.Sum(item => item.Value); + CurrentValueDict[pair.Key] = currentDownloadBytes; CurrentValue = CurrentValueDict.Sum(item => item.Value); } } @@ -353,27 +357,30 @@ void OnUpdateProgress(int _, int __, long totalDownloadBytes, long currentDownlo protected override IEnumerator OnWaitCo() { + CurrentValueDict.Clear(); + TotalValueDict.Clear(); + foreach (var pair in ResourceDownloaderOperations) { - CurrentValueDict[pair.Key] = pair.Value.CurrentDownloadBytes; TotalValueDict[pair.Key] = pair.Value.TotalDownloadBytes; + CurrentValueDict[pair.Key] = pair.Value.CurrentDownloadBytes; } - if (AssetSystem.GetAvailableDiskSpace() < TotalValue) // 检查磁盘空间是否足够 + TotalValue = TotalValueDict.Sum(pair => pair.Value); + CurrentValue = CurrentValueDict.Sum(pair => pair.Value); + + if (AssetSystem.GetAvailableDiskSpace() < TotalValue - CurrentValue) // 检查磁盘空间是否足够 { State = EProgressState.Fail; if (OnDiskSpaceNotEnough is null) - throw new Exception( + throw new SystemException( $"磁盘空间 {AssetSystem.GetAvailableDiskSpace().ToConverseStringFileSize()} < {TotalValue.ToConverseStringFileSize()}"); - OnDiskSpaceNotEnough.Invoke(Report); AssetSystem.LogException( $"磁盘空间 {AssetSystem.GetAvailableDiskSpace().ToConverseStringFileSize()} < {TotalValue.ToConverseStringFileSize()}"); + OnDiskSpaceNotEnough.Invoke(Report); yield break; } - TotalValue = TotalValueDict.Sum(pair => pair.Value); - CurrentValue = CurrentValueDict.Sum(pair => pair.Value); - foreach (var pair in ResourceDownloaderOperations) { CurrentInfo = $"Resource Download -> [{pair.Key}]"; @@ -400,10 +407,11 @@ protected override IEnumerator OnWaitCo() yield return pair.Value; if (pair.Value.Status == EOperationStatus.Succeed) continue; + State = EProgressState.Fail; yield break; - void OnUpdateProgress(int _, int __, long ___, long currentDownloadBytes) + void OnUpdateProgress(int _, int __, long totalDownloadBytes, long currentDownloadBytes) { if (State != EProgressState.Running) return; switch (Application.internetReachability) @@ -426,6 +434,8 @@ void OnUpdateProgress(int _, int __, long ___, long currentDownloadBytes) break; } + TotalValueDict[pair.Key] = totalDownloadBytes; + TotalValue = TotalValueDict.Sum(item => item.Value); CurrentValueDict[pair.Key] = currentDownloadBytes; CurrentValue = CurrentValueDict.Sum(item => item.Value); } From 954cd6825d33f4246dfbc1b1619770ae8c50a22f Mon Sep 17 00:00:00 2001 From: Starfire-Corporation-Win <1398581458@qq.com> Date: Fri, 26 Jan 2024 15:17:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20Up=20Version=201.0.31-preview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac3c0ad..47883c0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.aio.cli.asset", "displayName": "AIO Unity CLI Asset", "description": "AIO Unity CLI Asset", - "version": "1.0.30-preview", + "version": "1.0.31-preview", "unity": "2019.4", "unityRelease": "0f1", "license": "MIT",