Update DownloaderOperation.cs

This commit is contained in:
ALEXTANG
2023-04-13 11:48:34 +08:00
parent 74ae3fb349
commit b5d76e1f22

View File

@@ -34,6 +34,7 @@ namespace YooAsset
private int _lastDownloadCount = 0; private int _lastDownloadCount = 0;
private long _cachedDownloadBytes = 0; private long _cachedDownloadBytes = 0;
private int _cachedDownloadCount = 0; private int _cachedDownloadCount = 0;
private float _currentSpeed = 0f;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@@ -63,6 +64,14 @@ namespace YooAsset
get { return _lastDownloadBytes; } get { return _lastDownloadBytes; }
} }
/// <summary>
/// 当前下载器下载速度
/// </summary>
public float CurrentSpeed
{
get { return _currentSpeed; }
}
/// <summary> /// <summary>
/// 当下载器结束(无论成功或失败) /// 当下载器结束(无论成功或失败)
/// </summary> /// </summary>
@@ -150,6 +159,7 @@ namespace YooAsset
_cachedDownloadCount++; _cachedDownloadCount++;
_cachedDownloadBytes += bundleInfo.Bundle.FileSize; _cachedDownloadBytes += bundleInfo.Bundle.FileSize;
} }
_currentSpeed = downloadBytes / UnityEngine.Time.time;
// 移除已经完成的下载器(无论成功或失败) // 移除已经完成的下载器(无论成功或失败)
foreach (var loader in _removeList) foreach (var loader in _removeList)