diff --git a/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs b/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs index c23d0e9b..038a54a7 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs @@ -83,6 +83,7 @@ namespace YooAsset { if (_loadBundleOp == null) { + // 统计计数增加 _resManager.BundleLoadingCounter++; _loadBundleOp = LoadBundleInfo.LoadBundleFile(); _loadBundleOp.StartOperation(); @@ -163,11 +164,12 @@ namespace YooAsset { IsDestroyed = true; - // Check fatal + // 注意:正在加载中的任务不可以销毁 + if (_steps == ESteps.LoadBundleFile) + throw new Exception($"Bundle file loader is not done : {LoadBundleInfo.Bundle.BundleName}"); + if (RefCount > 0) throw new Exception($"Bundle file loader ref is not zero : {LoadBundleInfo.Bundle.BundleName}"); - if (IsDone == false) - throw new Exception($"Bundle file loader is not done : {LoadBundleInfo.Bundle.BundleName}"); if (Result != null) Result.UnloadBundleFile(); @@ -178,7 +180,8 @@ namespace YooAsset /// public bool CanDestroyLoader() { - if (IsDone == false) + // 注意:正在加载中的任务不可以销毁 + if (_steps == ESteps.LoadBundleFile) return false; if (RefCount > 0) diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs index c4079dce..458173ee 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs @@ -109,6 +109,13 @@ namespace YooAsset if (_steps == ESteps.None || _steps == ESteps.Done) return; + // 注意:未在加载中的任务可以挂起! + if (_steps != ESteps.ProcessBundleResult) + { + if (RefCount <= 0) + return; + } + if (_steps == ESteps.StartBundleLoader) { foreach (var bundleLoader in _bundleLoaders) @@ -192,8 +199,9 @@ namespace YooAsset // 检测是否为正常销毁 if (IsDone == false) { - Error = "User abort !"; + _steps = ESteps.Done; Status = EOperationStatus.Failed; + Error = "User abort !"; } // 减少引用计数 @@ -208,7 +216,7 @@ namespace YooAsset /// public bool CanDestroyProvider() { - // 注意:在进行资源加载过程时不可以销毁 + // 注意:正在加载中的任务不可以销毁 if (_steps == ESteps.ProcessBundleResult) return false;