diff --git a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs index 8e8d439..29302c5 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; @@ -158,5 +159,19 @@ namespace YooAsset private TaskCompletionSource _taskCompletionSource; #endregion + + #region 调试方法 + [Conditional("DEBUG")] + protected void DebugCheckWaitForAsyncComplete(string error = null) + { + if (IsDone == false) + { + if (string.IsNullOrEmpty(error)) + YooLogger.Error($"Operation {this.GetType().Name} failed to wait for async complete !"); + else + YooLogger.Error($"Operation {this.GetType().Name} failed to wait for async complete ! {error}"); + } + } + #endregion } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/ResourceManager/Operation/InstantiateOperation.cs b/Assets/YooAsset/Runtime/ResourceManager/Operation/InstantiateOperation.cs index 68158a4..1ecc5a2 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Operation/InstantiateOperation.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Operation/InstantiateOperation.cs @@ -77,10 +77,12 @@ namespace YooAsset /// public override void WaitForAsyncComplete() { - if (_steps == ESteps.Done) - return; - _handle.WaitForAsyncComplete(); - InternalOnUpdate(); + if (_steps == ESteps.Clone) + { + _handle.WaitForAsyncComplete(); + InternalOnUpdate(); + DebugCheckWaitForAsyncComplete(); + } } /// diff --git a/Assets/YooAsset/Runtime/ResourceManager/Operation/UnloadUnusedAssetsOperation.cs b/Assets/YooAsset/Runtime/ResourceManager/Operation/UnloadUnusedAssetsOperation.cs index 9c4708d..b99b302 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Operation/UnloadUnusedAssetsOperation.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Operation/UnloadUnusedAssetsOperation.cs @@ -1,5 +1,4 @@ -using System; -using UnityEngine; +using UnityEngine; namespace YooAsset { @@ -58,5 +57,10 @@ namespace YooAsset Status = EOperationStatus.Succeed; } } + public override void WaitForAsyncComplete() + { + InternalOnUpdate(); + DebugCheckWaitForAsyncComplete(); + } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAllAssetsProvider.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAllAssetsProvider.cs index d8a9604..388a427 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAllAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAllAssetsProvider.cs @@ -42,9 +42,7 @@ namespace YooAsset if (_steps == ESteps.CheckBundle) { if (IsWaitForAsyncComplete) - { FileLoader.WaitForAsyncComplete(); - } if (FileLoader.IsDone() == false) return; diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAssetProvider.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAssetProvider.cs index 3e0d5a8..23a6e8e 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAssetProvider.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseAssetProvider.cs @@ -42,9 +42,7 @@ namespace YooAsset if (_steps == ESteps.CheckBundle) { if (IsWaitForAsyncComplete) - { FileLoader.WaitForAsyncComplete(); - } if (FileLoader.IsDone() == false) return; diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseRawFileProvider.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseRawFileProvider.cs index c2c7ea1..12e47c9 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseRawFileProvider.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseRawFileProvider.cs @@ -39,9 +39,7 @@ namespace YooAsset if (_steps == ESteps.CheckBundle) { if (IsWaitForAsyncComplete) - { FileLoader.WaitForAsyncComplete(); - } if (FileLoader.IsDone() == false) return; diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSceneProvider.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSceneProvider.cs index cf779e7..87e708d 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSceneProvider.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSceneProvider.cs @@ -37,9 +37,7 @@ namespace YooAsset if (_steps == ESteps.CheckBundle) { if (IsWaitForAsyncComplete) - { FileLoader.WaitForAsyncComplete(); - } if (FileLoader.IsDone() == false) return; diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSubAssetsProvider.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSubAssetsProvider.cs index 53706d5..9f064d5 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/DatabaseSubAssetsProvider.cs @@ -42,9 +42,7 @@ namespace YooAsset if (_steps == ESteps.CheckBundle) { if (IsWaitForAsyncComplete) - { FileLoader.WaitForAsyncComplete(); - } if (FileLoader.IsDone() == false) return; diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderBase.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderBase.cs index 4c50af1..cceef4b 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderBase.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderBase.cs @@ -102,12 +102,7 @@ namespace YooAsset // 注意:主动轮询更新完成同步加载 InternalOnUpdate(); - - // 验证结果 - if (IsDone == false) - { - YooLogger.Warning($"{nameof(WaitForAsyncComplete)} failed to loading : {MainAssetInfo.AssetPath}"); - } + DebugCheckWaitForAsyncComplete($"Loading asset {MainAssetInfo.AssetPath}"); } ///