com.alicizax.unity.tuyoogam.../Runtime/FileSystem/Operation/FSDownloadFileOperation.cs

74 lines
1.8 KiB
C#
Raw Normal View History

2025-01-09 11:31:04 +08:00

namespace YooAsset
{
2025-05-13 10:40:30 +08:00
internal class DownloadFileOptions
{
/// <summary>
/// 失败后重试次数
/// </summary>
public readonly int FailedTryAgain;
/// <summary>
/// 主资源地址
/// </summary>
2025-09-02 19:21:49 +08:00
public string MainURL { private set; get; }
2025-05-13 10:40:30 +08:00
/// <summary>
/// 备用资源地址
/// </summary>
2025-09-02 19:21:49 +08:00
public string FallbackURL { private set; get; }
2025-05-13 10:40:30 +08:00
/// <summary>
2025-09-02 19:21:49 +08:00
/// 拷贝的本地文件路径
2025-05-13 10:40:30 +08:00
/// </summary>
public string ImportFilePath { set; get; }
2025-09-02 19:21:49 +08:00
public DownloadFileOptions(int failedTryAgain)
2025-05-13 10:40:30 +08:00
{
FailedTryAgain = failedTryAgain;
}
2025-01-09 11:31:04 +08:00
/// <summary>
2025-09-02 19:21:49 +08:00
/// 设置下载地址
2025-01-09 11:31:04 +08:00
/// </summary>
2025-09-02 19:21:49 +08:00
public void SetURL(string mainURL, string fallbackURL)
{
MainURL = mainURL;
FallbackURL = fallbackURL;
}
2025-01-09 11:31:04 +08:00
/// <summary>
2025-09-02 19:21:49 +08:00
/// 是否有效
2025-01-09 11:31:04 +08:00
/// </summary>
2025-09-02 19:21:49 +08:00
public bool IsValid()
{
if (string.IsNullOrEmpty(MainURL) || string.IsNullOrEmpty(FallbackURL))
return false;
return true;
}
}
internal abstract class FSDownloadFileOperation : AsyncOperationBase
{
public PackageBundle Bundle { private set; get; }
2025-01-09 11:31:04 +08:00
/// <summary>
/// 当前下载的字节数
/// </summary>
public long DownloadedBytes { protected set; get; }
/// <summary>
/// 当前下载进度0f - 1f
/// </summary>
public float DownloadProgress { protected set; get; }
public FSDownloadFileOperation(PackageBundle bundle)
{
Bundle = bundle;
DownloadedBytes = 0;
DownloadProgress = 0;
}
}
}