| | 1 | | using DCL.SettingsCommon.SettingsControllers.BaseControllers; |
| | 2 | | using UnityEngine; |
| | 3 | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | 4 | | using System.Runtime.InteropServices; |
| | 5 | | #endif |
| | 6 | |
|
| | 7 | | namespace DCL.SettingsCommon.SettingsControllers.SpecificControllers |
| | 8 | | { |
| | 9 | | [CreateAssetMenu(menuName = "Settings/Controllers/Controls/FPS Limit", fileName = "FPSLimitControlController")] |
| | 10 | | public class FPSLimitControlController : ToggleSettingsControlController |
| | 11 | | { |
| | 12 | | const int MAX_FPS = 240; |
| | 13 | |
|
| 2 | 14 | | public override object GetStoredValue() { return currentQualitySetting.fpsCap; } |
| | 15 | |
|
| | 16 | | public override void UpdateSetting(object newValue) |
| | 17 | | { |
| 2 | 18 | | currentQualitySetting.fpsCap = (bool)newValue; |
| 2 | 19 | | ToggleFPSCap(currentQualitySetting.fpsCap); |
| 2 | 20 | | } |
| | 21 | |
|
| | 22 | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | 23 | | [DllImport("__Internal")] public static extern void ToggleFPSCap(bool useFPSCap); |
| | 24 | | #else |
| | 25 | | public static void ToggleFPSCap(bool useFPSCap) |
| | 26 | | { |
| 2 | 27 | | Application.targetFrameRate = useFPSCap ? 30 : MAX_FPS; |
| 2 | 28 | | } |
| | 29 | | #endif |
| | 30 | | } |
| | 31 | | } |