update patch system
parent
c27a3e105c
commit
a9a01b08dc
|
@ -32,28 +32,36 @@ namespace YooAsset
|
||||||
private bool _isPause = false;
|
private bool _isPause = false;
|
||||||
private long _lastDownloadBytes = 0;
|
private long _lastDownloadBytes = 0;
|
||||||
private int _lastDownloadCount = 0;
|
private int _lastDownloadCount = 0;
|
||||||
|
private long _cachedDownloadBytes = 0;
|
||||||
|
private int _cachedDownloadCount = 0;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载文件总数量
|
/// 统计的下载文件总数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TotalDownloadCount { private set; get; }
|
public int TotalDownloadCount { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载文件的总大小
|
/// 统计的下载文件的总大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long TotalDownloadBytes { private set; get; }
|
public long TotalDownloadBytes { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前已经完成的下载总数量
|
/// 当前已经完成的下载总数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CurrentDownloadCount { private set; get; }
|
public int CurrentDownloadCount
|
||||||
|
{
|
||||||
|
get { return _lastDownloadCount; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前已经完成的下载总大小
|
/// 当前已经完成的下载总大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long CurrentDownloadBytes { private set; get; }
|
public long CurrentDownloadBytes
|
||||||
|
{
|
||||||
|
get { return _lastDownloadBytes; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当下载器结束(无论成功或失败)
|
/// 当下载器结束(无论成功或失败)
|
||||||
|
@ -120,7 +128,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
// 检测下载器结果
|
// 检测下载器结果
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
long downloadBytes = CurrentDownloadBytes;
|
long downloadBytes = _cachedDownloadBytes;
|
||||||
foreach (var downloader in _downloaders)
|
foreach (var downloader in _downloaders)
|
||||||
{
|
{
|
||||||
downloadBytes += (long)downloader.DownloadedBytes;
|
downloadBytes += (long)downloader.DownloadedBytes;
|
||||||
|
@ -139,8 +147,8 @@ namespace YooAsset
|
||||||
|
|
||||||
// 下载成功
|
// 下载成功
|
||||||
_removeList.Add(downloader);
|
_removeList.Add(downloader);
|
||||||
CurrentDownloadCount++;
|
_cachedDownloadCount++;
|
||||||
CurrentDownloadBytes += bundleInfo.Bundle.FileSize;
|
_cachedDownloadBytes += bundleInfo.Bundle.FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除已经完成的下载器(无论成功或失败)
|
// 移除已经完成的下载器(无论成功或失败)
|
||||||
|
@ -150,10 +158,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果下载进度发生变化
|
// 如果下载进度发生变化
|
||||||
if (_lastDownloadBytes != downloadBytes || _lastDownloadCount != CurrentDownloadCount)
|
if (_lastDownloadBytes != downloadBytes || _lastDownloadCount != _cachedDownloadCount)
|
||||||
{
|
{
|
||||||
_lastDownloadBytes = downloadBytes;
|
_lastDownloadBytes = downloadBytes;
|
||||||
_lastDownloadCount = CurrentDownloadCount;
|
_lastDownloadCount = _cachedDownloadCount;
|
||||||
Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
|
Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
|
||||||
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
|
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue