Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
|
- using System;
- using System.Collections.Generic;
- using SUISS.Core;
- using UnityEngine;
-
- public sealed class FPSLimiter : SingletonMonobehaviour<FPSLimiter>
- {
- protected override void Awake()
- {
- base.Awake();
- if (this._isValidNewInstance)
- {
- UnityEngine.Object.DontDestroyOnLoad(this);
- Application.targetFrameRate = 30;
- }
- }
-
- public void PushUnlimitedFPSRequest(object requester)
- {
- if (this._unlimitedFPSRequesters.Count == 0)
- {
- Application.targetFrameRate = 60;
- }
- if (!this._unlimitedFPSRequesters.Contains(requester))
- {
- this._unlimitedFPSRequesters.Add(requester);
- }
- }
-
- public void PopUnlimitedFPSRequest(object requester)
- {
- this._unlimitedFPSRequesters.Remove(requester);
- if (this._unlimitedFPSRequesters.Count == 0)
- {
- Application.targetFrameRate = 30;
- }
- }
-
- private const int UnlimitedFPS = 60;
-
- private const int LimitedFPS = 30;
-
- private List<object> _unlimitedFPSRequesters = new List<object>();
- }
|