YooAssetsDriver.cs 602 B

12345678910111213141516171819202122232425262728
  1. using System.Diagnostics;
  2. using UnityEngine;
  3. namespace YooAsset
  4. {
  5. internal class YooAssetsDriver : MonoBehaviour
  6. {
  7. private static int LastestUpdateFrame = 0;
  8. void Update()
  9. {
  10. DebugCheckDuplicateDriver();
  11. YooAssets.Update();
  12. }
  13. [Conditional("DEBUG")]
  14. private void DebugCheckDuplicateDriver()
  15. {
  16. if (LastestUpdateFrame > 0)
  17. {
  18. if (LastestUpdateFrame == Time.frameCount)
  19. YooLogger.Warning($"There are two {nameof(YooAssetsDriver)} in the scene. Please ensure there is always exactly one driver in the scene.");
  20. }
  21. LastestUpdateFrame = Time.frameCount;
  22. }
  23. }
  24. }