This commit is contained in:
何冠峰
2025-10-30 18:31:06 +08:00
parent 2a956099ae
commit d570ba8d74
7 changed files with 136 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ namespace YooAsset
None,
CheckExist,
DownloadFile,
AbortDownload,
LoadAssetBundle,
CheckResult,
Done,
@@ -63,6 +64,17 @@ namespace YooAsset
}
}
if (_steps == ESteps.DownloadFile)
{
// 中断下载
if (AbortDownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.AbortOperation();
_steps = ESteps.AbortDownload;
}
}
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp == null)
@@ -94,6 +106,23 @@ namespace YooAsset
}
}
if (_steps == ESteps.AbortDownload)
{
if (_downloadFileOp != null)
{
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
if (_downloadFileOp.IsDone == false)
return;
}
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort download file !";
}
if (_steps == ESteps.LoadAssetBundle)
{
if (_bundle.Encrypted)
@@ -251,6 +280,7 @@ namespace YooAsset
None,
CheckExist,
DownloadFile,
AbortDownload,
LoadCacheRawBundle,
Done,
}
@@ -310,6 +340,17 @@ namespace YooAsset
}
}
if (_steps == ESteps.DownloadFile)
{
// 中断下载
if (AbortDownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.AbortOperation();
_steps = ESteps.AbortDownload;
}
}
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp == null)
@@ -341,6 +382,23 @@ namespace YooAsset
}
}
if (_steps == ESteps.AbortDownload)
{
if (_downloadFileOp != null)
{
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
if (_downloadFileOp.IsDone == false)
return;
}
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort download file !";
}
if (_steps == ESteps.LoadCacheRawBundle)
{
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);

View File

@@ -8,6 +8,7 @@ namespace YooAsset
None,
CheckExist,
DownloadFile,
AbortDownload,
LoadAssetBundle,
CheckResult,
Done,
@@ -48,6 +49,17 @@ namespace YooAsset
}
}
if (_steps == ESteps.DownloadFile)
{
// 中断下载
if (AbortDownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.AbortOperation();
_steps = ESteps.AbortDownload;
}
}
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp == null)
@@ -79,6 +91,23 @@ namespace YooAsset
}
}
if (_steps == ESteps.AbortDownload)
{
if (_downloadFileOp != null)
{
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
if (_downloadFileOp.IsDone == false)
return;
}
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort download file !";
}
if (_steps == ESteps.LoadAssetBundle)
{
if (IsWaitForAsyncComplete)

View File

@@ -17,6 +17,11 @@ namespace YooAsset
/// 下载大小
/// </summary>
public long DownloadedBytes { protected set; get; } = 0;
/// <summary>
/// 终止下载文件
/// </summary>
public bool AbortDownloadFile = false;
}
internal sealed class FSLoadBundleCompleteOperation : FSLoadBundleOperation