diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs index 56bd186..a9affbe 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs @@ -13,7 +13,7 @@ namespace YooAsset } public override void Update() { - DebugRecording(); + DebugBeginRecording(); if (IsDone) return; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs index 80a2a9f..59b0fc4 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs @@ -8,7 +8,7 @@ namespace YooAsset } public override void Update() { - DebugRecording(); + DebugBeginRecording(); if (IsDone) return; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs index 6a9bd22..7821b86 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs @@ -23,7 +23,7 @@ namespace YooAsset } public override void Update() { - DebugRecording(); + DebugBeginRecording(); if (IsDone) return; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs index 800a548..36d8b36 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs @@ -13,7 +13,7 @@ namespace YooAsset } public override void Update() { - DebugRecording(); + DebugBeginRecording(); if (IsDone) return; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs index b541aff..2522739 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs @@ -221,6 +221,8 @@ namespace YooAsset private TaskCompletionSource _taskCompletionSource; protected void InvokeCompletion() { + DebugEndRecording(); + // 进度百分百完成 Progress = 1f; @@ -256,8 +258,7 @@ namespace YooAsset public long LoadingTime { protected set; get; } // 加载耗时统计 - private bool _isRecording = false; - private Stopwatch _watch; + private Stopwatch _watch = null; [Conditional("DEBUG")] public void InitSpawnDebugInfo() @@ -274,21 +275,21 @@ namespace YooAsset } [Conditional("DEBUG")] - protected void DebugRecording() + protected void DebugBeginRecording() { - if (_isRecording == false) + if (_watch == null) { - _isRecording = true; _watch = Stopwatch.StartNew(); } + } + [Conditional("DEBUG")] + private void DebugEndRecording() + { if (_watch != null) { - if (IsDone) - { - LoadingTime = _watch.ElapsedMilliseconds; - _watch = null; - } + LoadingTime = _watch.ElapsedMilliseconds; + _watch = null; } } #endregion