[增加]增加下载状态变化的时候包名称的返回

1.主要是如果在同时下载包的时候且注册到统一的返回事件的时候无法识别当前是什么包下载的返回结果.这样给开发者有一定的操作成本.需要独立的去记录包和下载列表的关系
pull/353/head
Blank 2024-08-27 19:19:42 +08:00 committed by GitHub
parent dda2a4c659
commit 60fe96fb9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 10 deletions

View File

@ -15,10 +15,10 @@ namespace YooAsset
private const int MAX_LOADER_COUNT = 64; private const int MAX_LOADER_COUNT = 64;
public delegate void OnDownloadOver(bool isSucceed); public delegate void OnDownloadOver(string packageName, bool isSucceed);
public delegate void OnDownloadProgress(int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes); public delegate void OnDownloadProgress(string packageName, int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes);
public delegate void OnDownloadError(string fileName, string error); public delegate void OnDownloadError(string packageName, string fileName, string error);
public delegate void OnStartDownloadFile(string fileName, long sizeBytes); public delegate void OnStartDownloadFile(string packageName, string fileName, long sizeBytes);
private readonly string _packageName; private readonly string _packageName;
private readonly int _downloadingMaxNumber; private readonly int _downloadingMaxNumber;
@ -160,7 +160,7 @@ namespace YooAsset
_lastDownloadBytes = downloadBytes; _lastDownloadBytes = downloadBytes;
_lastDownloadCount = _cachedDownloadCount; _lastDownloadCount = _cachedDownloadCount;
Progress = (float)_lastDownloadBytes / TotalDownloadBytes; Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes); OnDownloadProgressCallback?.Invoke(GetPackageName(), TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
} }
// 动态创建新的下载器到最大数量限制 // 动态创建新的下载器到最大数量限制
@ -177,7 +177,7 @@ namespace YooAsset
var downloader = bundleInfo.CreateDownloader(_failedTryAgain, _timeout); var downloader = bundleInfo.CreateDownloader(_failedTryAgain, _timeout);
_downloaders.Add(downloader); _downloaders.Add(downloader);
_bundleInfoList.RemoveAt(index); _bundleInfoList.RemoveAt(index);
OnStartDownloadFileCallback?.Invoke(bundleInfo.Bundle.BundleName, bundleInfo.Bundle.FileSize); OnStartDownloadFileCallback?.Invoke(GetPackageName(), bundleInfo.Bundle.BundleName, bundleInfo.Bundle.FileSize);
} }
} }
@ -191,15 +191,15 @@ namespace YooAsset
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Failed to download file : {bundleName}"; Error = $"Failed to download file : {bundleName}";
OnDownloadErrorCallback?.Invoke(bundleName, failedDownloader.Error); OnDownloadErrorCallback?.Invoke(GetPackageName(), bundleName, failedDownloader.Error);
OnDownloadOverCallback?.Invoke(false); OnDownloadOverCallback?.Invoke(GetPackageName(), false);
} }
else else
{ {
// 结算成功 // 结算成功
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
OnDownloadOverCallback?.Invoke(true); OnDownloadOverCallback?.Invoke(GetPackageName(), true);
} }
} }
} }
@ -361,4 +361,4 @@ namespace YooAsset
return operation; return operation;
} }
} }
} }