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
@@ -173,6 +173,13 @@ namespace YooAsset
if (Result != null)
Result.UnloadBundleFile();
if (IsDone == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Bundle loader destroyed !";
}
}
/// <summary>
@@ -256,5 +263,28 @@ namespace YooAsset
_removeList.Clear();
}
}
/// <summary>
/// 尝试终止加载器
/// </summary>
public void TryAbortLoader()
{
if (IsDone == false)
{
if (_steps == ESteps.CheckConcurrency)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort bundle loader !";
}
if (_steps == ESteps.LoadBundleFile)
{
// 注意:终止下载器
if (_loadBundleOp != null)
_loadBundleOp.AbortDownloadFile = true;
}
}
}
}
}
@@ -23,7 +23,7 @@ namespace YooAsset
None,
CheckOptions,
ReleaseAll,
AbortDownload,
TryAbortLoader,
CheckLoading,
DestroyAll,
Done,
@@ -78,15 +78,16 @@ namespace YooAsset
}
}
_steps = ESteps.AbortDownload;
_steps = ESteps.TryAbortLoader;
}
if (_steps == ESteps.AbortDownload)
if (_steps == ESteps.TryAbortLoader)
{
// 注意:终止所有下载任务
// 尝试终止所有加载任务
// 注意:正在加载AssetBundle的任务无法终止
foreach (var loader in _resManager.LoaderDic.Values)
{
loader.AbortOperation();
loader.TryAbortLoader();
}
_steps = ESteps.CheckLoading;
}