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); } 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",