From 25231ecd326be5d8db2d6e7774b250dc63784202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Sun, 7 Jul 2024 09:45:01 +0800 Subject: [PATCH] update resource manager --- .../Runtime/OperationSystem/AsyncOperationBase.cs | 15 +++++++++++++++ .../Operation/InstantiateOperation.cs | 10 ++++++---- .../Operation/UnloadUnusedAssetsOperation.cs | 8 ++++++-- .../Provider/DatabaseAllAssetsProvider.cs | 2 -- .../Provider/DatabaseAssetProvider.cs | 2 -- .../Provider/DatabaseRawFileProvider.cs | 2 -- .../Provider/DatabaseSceneProvider.cs | 2 -- .../Provider/DatabaseSubAssetsProvider.cs | 2 -- .../ResourceManager/Provider/ProviderBase.cs | 7 +------ 9 files changed, 28 insertions(+), 22 deletions(-) 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}"); } ///