Files
YooAsset/Assets/YooAsset/Runtime/YooAssetsDriver.cs

35 lines
861 B
C#
Raw Normal View History

2022-11-03 10:37:34 +08:00
using System.Diagnostics;
using UnityEngine;
2022-03-03 18:07:58 +08:00
namespace YooAsset
{
2023-12-21 19:10:46 +08:00
internal class YooAssetsDriver : MonoBehaviour
{
private static int LastestUpdateFrame = 0;
2022-11-03 10:37:34 +08:00
2023-12-21 19:10:46 +08:00
void Update()
{
DebugCheckDuplicateDriver();
YooAssets.Update();
}
2022-11-03 10:37:34 +08:00
#if UNITY_EDITOR
void OnApplicationQuit()
{
YooAssets.OnApplicationQuit();
}
#endif
2023-12-21 19:10:46 +08:00
[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.");
}
2022-11-03 10:37:34 +08:00
2023-12-21 19:10:46 +08:00
LastestUpdateFrame = Time.frameCount;
}
}
2022-03-03 18:07:58 +08:00
}