From 9db111c08aa4125a2ef0c415678ef7755be2e17f Mon Sep 17 00:00:00 2001 From: hevinci Date: Thu, 3 Nov 2022 10:37:34 +0800 Subject: [PATCH] Update runtime code --- .../Runtime/CacheSystem/EVerifyResult.cs | 2 +- Assets/YooAsset/Runtime/YooAssetsDriver.cs | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Assets/YooAsset/Runtime/CacheSystem/EVerifyResult.cs b/Assets/YooAsset/Runtime/CacheSystem/EVerifyResult.cs index c59e8bc..6d4b48f 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/EVerifyResult.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/EVerifyResult.cs @@ -4,7 +4,7 @@ namespace YooAsset /// /// 下载文件校验结果 /// - public enum EVerifyResult + internal enum EVerifyResult { /// /// 文件不存在 diff --git a/Assets/YooAsset/Runtime/YooAssetsDriver.cs b/Assets/YooAsset/Runtime/YooAssetsDriver.cs index bd84663..adb28c2 100644 --- a/Assets/YooAsset/Runtime/YooAssetsDriver.cs +++ b/Assets/YooAsset/Runtime/YooAssetsDriver.cs @@ -1,22 +1,36 @@ -using UnityEngine; +using System.Diagnostics; +using UnityEngine; namespace YooAsset { internal class YooAssetsDriver : MonoBehaviour { + private static int LastestUpdateFrame = 0; + void Update() { + DebugCheckDuplicateDriver(); YooAssets.Update(); } - void OnDestroy() { YooAssets.Destroy(); } - void OnApplicationQuit() { YooAssets.Destroy(); } + + [Conditional("DEBUG")] + private void DebugCheckDuplicateDriver() + { + if (LastestUpdateFrame > 0) + { + if (LastestUpdateFrame == Time.frameCount) + YooLogger.Warning($"There are two {nameof(YooAssetsDriver)} in the scene. Please ensure there is always exactly one driver in the scene."); + } + + LastestUpdateFrame = Time.frameCount; + } } } \ No newline at end of file