| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System.Diagnostics;
- using UnityEngine;
- namespace YooAsset
- {
- internal class YooAssetsDriver : MonoBehaviour
- {
- #if UNITY_EDITOR
- [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
- private static void OnRuntimeInitialize()
- {
- LastestUpdateFrame = 0;
- }
- #endif
- private static int LastestUpdateFrame = 0;
- void Update()
- {
- DebugCheckDuplicateDriver();
- YooAssets.Update();
- }
- #if UNITY_EDITOR
- void OnApplicationQuit()
- {
- YooAssets.OnApplicationQuit();
- }
- #endif
- [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;
- }
- }
- }
|