Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

45 righe
996 B

  1. using System;
  2. using System.Collections.Generic;
  3. using SUISS.Core;
  4. using UnityEngine;
  5. public sealed class FPSLimiter : SingletonMonobehaviour<FPSLimiter>
  6. {
  7. protected override void Awake()
  8. {
  9. base.Awake();
  10. if (this._isValidNewInstance)
  11. {
  12. UnityEngine.Object.DontDestroyOnLoad(this);
  13. Application.targetFrameRate = 30;
  14. }
  15. }
  16. public void PushUnlimitedFPSRequest(object requester)
  17. {
  18. if (this._unlimitedFPSRequesters.Count == 0)
  19. {
  20. Application.targetFrameRate = 60;
  21. }
  22. if (!this._unlimitedFPSRequesters.Contains(requester))
  23. {
  24. this._unlimitedFPSRequesters.Add(requester);
  25. }
  26. }
  27. public void PopUnlimitedFPSRequest(object requester)
  28. {
  29. this._unlimitedFPSRequesters.Remove(requester);
  30. if (this._unlimitedFPSRequesters.Count == 0)
  31. {
  32. Application.targetFrameRate = 30;
  33. }
  34. }
  35. private const int UnlimitedFPS = 60;
  36. private const int LimitedFPS = 30;
  37. private List<object> _unlimitedFPSRequesters = new List<object>();
  38. }