From ae075b1fad62f15680151dd63a12674c32da02c8 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Wed, 29 Nov 2023 12:55:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3ProcedureDownloadFile?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E7=BD=91=E9=80=9F=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正ProcedureDownloadFile更新时网速计算 --- .../Main/Procedure/ProcedureDownloadFile.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureDownloadFile.cs b/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureDownloadFile.cs index e0409b1a..cf5b6cf7 100644 --- a/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureDownloadFile.cs +++ b/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureDownloadFile.cs @@ -13,9 +13,18 @@ namespace GameMain private ProcedureOwner _procedureOwner; - private float CurrentSpeed => - (GameModule.Resource.Downloader.TotalDownloadBytes - - GameModule.Resource.Downloader.CurrentDownloadBytes) / GameTime.time; + private float _lastUpdateDownloadedSize; + private float CurrentSpeed + { + get + { + float interval = GameTime.deltaTime; + var sizeDiff = GameModule.Resource.Downloader.CurrentDownloadBytes - _lastUpdateDownloadedSize; + _lastUpdateDownloadedSize = GameModule.Resource.Downloader.CurrentDownloadBytes; + var speed = (float)Math.Floor(sizeDiff / interval); + return speed; + } + } protected override void OnEnter(ProcedureOwner procedureOwner) { @@ -63,7 +72,7 @@ namespace GameMain Utility.File.GetByteLengthString(currentDownloadBytes), Utility.File.GetByteLengthString(totalDownloadBytes), GameModule.Resource.Downloader.Progress, - Utility.File.GetByteLengthString((int)CurrentSpeed)); + Utility.File.GetLengthString((int)CurrentSpeed)); LoadUpdateLogic.Instance.DownProgressAction?.Invoke(GameModule.Resource.Downloader.Progress); UILoadMgr.Show(UIDefine.UILoadUpdate,descriptionText);