refactor : 重构代码

This commit is contained in:
何冠峰
2026-01-17 17:06:57 +08:00
parent da222c6179
commit e10888de93
13 changed files with 42 additions and 43 deletions
@@ -19,17 +19,17 @@ namespace YooAsset
/// <summary>
/// 所属包裹
/// </summary>
public string PackageName { private set; get; }
public string PackageName { get; private set; }
/// <summary>
/// 资源类型
/// </summary>
public System.Type AssetType { private set; get; }
public System.Type AssetType { get; private set; }
/// <summary>
/// 错误信息
/// </summary>
public string Error { private set; get; }
public string Error { get; private set; }
/// <summary>
/// 加载方法
@@ -6,17 +6,17 @@ namespace YooAsset
/// <summary>
/// 清理模式
/// </summary>
public string ClearMode { set; get; }
public string ClearMode { get; set; }
/// <summary>
/// 附加参数
/// </summary>
public object ClearParam { set; get; }
public object ClearParam { get; set; }
/// <summary>
/// 资源清单
/// </summary>
internal PackageManifest Manifest { set; get; }
internal PackageManifest Manifest { get; set; }
public ClearCacheFilesOptions(EFileClearMode clearMode)
{
@@ -35,12 +35,12 @@ namespace YooAsset
/// <summary>
/// 统计的下载文件总数量
/// </summary>
public int TotalDownloadCount { private set; get; }
public int TotalDownloadCount { get; private set; }
/// <summary>
/// 统计的下载文件的总大小
/// </summary>
public long TotalDownloadBytes { private set; get; }
public long TotalDownloadBytes { get; private set; }
/// <summary>
/// 当前已经完成的下载总数量
@@ -61,29 +61,29 @@ namespace YooAsset
/// <summary>
/// 下载完成事件委托(无论成功或失败)
/// </summary>
public DownloadFinishedEventHandler DownloadFinishedHandler { set; get; }
public DownloadFinishedEventHandler DownloadFinishedHandler { get; set; }
/// <summary>
/// 下载进度更新事件委托
/// </summary>
public DownloadProgressChangedEventHandler DownloadProgressChangedHandler { set; get; }
public DownloadProgressChangedEventHandler DownloadProgressChangedHandler { get; set; }
/// <summary>
/// 下载错误事件委托
/// </summary>
public DownloadErrorEventHandler DownloadErrorHandler { set; get; }
public DownloadErrorEventHandler DownloadErrorHandler { get; set; }
/// <summary>
/// 开始下载单个文件事件委托
/// </summary>
public DownloadFileStartedEventHandler DownloadFileStartedHandler { set; get; }
public DownloadFileStartedEventHandler DownloadFileStartedHandler { get; set; }
internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int maximumConcurrency, int failedTryAgain)
{
_packageName = packageName;
_bundleInfoList = downloadList;
_maximumConcurrency = UnityEngine.Mathf.Clamp(maximumConcurrency, 1, MAX_LOADER_COUNT); ;
_maximumConcurrency = UnityEngine.Mathf.Clamp(maximumConcurrency, 1, MAX_LOADER_COUNT);
_failedTryAgain = failedTryAgain;
// 统计下载信息
@@ -91,7 +91,7 @@ namespace YooAsset
}
internal override void InternalStart()
{
YooLogger.Log($"Begine to download {TotalDownloadCount} files and {TotalDownloadBytes} bytes");
YooLogger.Log($"Begin to download {TotalDownloadCount} files and {TotalDownloadBytes} bytes");
_steps = ESteps.Check;
}
internal override void InternalUpdate()
@@ -9,23 +9,23 @@ namespace YooAsset
/// <summary>
/// 最大并发数量
/// </summary>
public int MaximumConcurrency { set; get; }
public int MaximumConcurrency { get; set; }
/// <summary>
/// 失败后的重试次数
/// </summary>
public int FailedTryAgain { set; get; }
public int FailedTryAgain { get; set; }
/// <summary>
/// 下载资源对象所属资源包内所有资源对象依赖的资源包
/// </summary>
public bool DownloadBundleDependencies { set; get; }
public bool DownloadBundleDependencies { get; set; }
/// <summary>
/// 资源信息列表
/// 说明:如果列表为NULL,则下载所有资产
/// </summary>
public AssetInfo[] AssetInfos { set; get; }
public AssetInfo[] AssetInfos { get; set; }
public BundleDownloaderOptions(AssetInfo assetInfo, bool downloadDependencies, int maximumConcurrency, int failedTryAgain)
{
@@ -51,18 +51,18 @@ namespace YooAsset
/// <summary>
/// 最大并发数量
/// </summary>
public int MaximumConcurrency { set; get; }
public int MaximumConcurrency { get; set; }
/// <summary>
/// 失败后的重试次数
/// </summary>
public int FailedTryAgain { set; get; }
public int FailedTryAgain { get; set; }
/// <summary>
/// 资源标签列表
/// 说明:如果列表为NULL,则下载所有资产
/// </summary>
public string[] Tags { set; get; }
public string[] Tags { get; set; }
public ResourceDownloaderOptions(int maximumConcurrency, int failedTryAgain)
{
@@ -92,18 +92,18 @@ namespace YooAsset
/// <summary>
/// 最大并发数量
/// </summary>
public int MaximumConcurrency { set; get; }
public int MaximumConcurrency { get; set; }
/// <summary>
/// 失败后的重试次数
/// </summary>
public int FailedTryAgain { set; get; }
public int FailedTryAgain { get; set; }
/// <summary>
/// 资源标签列表
/// 说明:如果列表为NULL,则解压所有资产
/// </summary>
public string[] Tags { set; get; }
public string[] Tags { get; set; }
public ResourceUnpackerOptions(int maximumConcurrency, int failedTryAgain)
{
@@ -133,17 +133,17 @@ namespace YooAsset
/// <summary>
/// 最大并发数量
/// </summary>
public int MaximumConcurrency { set; get; }
public int MaximumConcurrency { get; set; }
/// <summary>
/// 失败后的重试次数
/// </summary>
public int FailedTryAgain { set; get; }
public int FailedTryAgain { get; set; }
/// <summary>
/// 资源包信息列表
/// </summary>
public ImportBundleInfo[] BundleInfos { set; get; }
public ImportBundleInfo[] BundleInfos { get; set; }
public BundleImporterOptions(ImportBundleInfo[] bundleInfos, int maximumConcurrency, int failedTryAgain)
{
@@ -6,12 +6,12 @@ namespace YooAsset
/// <summary>
/// 包裹版本
/// </summary>
public string PackageVersion { set; get; }
public string PackageVersion { get; set; }
/// <summary>
/// 超时时间
/// </summary>
public int Timeout { set; get; }
public int Timeout { get; set; }
public LoadPackageManifestOptions(string packageVersion, int timeout)
{
@@ -6,12 +6,12 @@ namespace YooAsset
/// <summary>
/// 预下载的包裹版本
/// </summary>
public string PackageVersion { set; get; }
public string PackageVersion { get; set; }
/// <summary>
/// 资源清单请求超时时间
/// </summary>
public int Timeout { set; get; }
public int Timeout { get; set; }
public PreDownloadContentOptions(string packageVersion, int timeout)
{
@@ -18,7 +18,7 @@ namespace YooAsset
/// <summary>
/// 当前最新的包裹版本
/// </summary>
public string PackageVersion { private set; get; }
public string PackageVersion { get; private set; }
internal RequestPackageVersionOperation(FileSystemHost host, RequestPackageVersionOptions options)
@@ -6,12 +6,12 @@ namespace YooAsset
/// <summary>
/// 在URL末尾添加时间戳
/// </summary>
public bool AppendTimeTicks { set; get; }
public bool AppendTimeTicks { get; set; }
/// <summary>
/// 超时时间
/// </summary>
public int Timeout { set; get; }
public int Timeout { get; set; }
public RequestPackageVersionOptions(bool appendTimeTicks, int timeout)
{
@@ -900,7 +900,7 @@ namespace YooAsset
else if (InitializeStatus == EOperationStatus.Failed)
{
string error = _initializeOp == null ? string.Empty : _initializeOp.Error;
throw new YooPackageException(PackageName, $"Resource package initialization failed! Error : {error}");
throw new YooPackageException(PackageName, $"Resource package initialization failed! Error: {error}");
}
}