Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Sirenix.OdinInspector;
- using UnityEngine;
- namespace Managers
- {
- public class GraphicSettings : MonoBehaviour
- {
- #region Values
- #endregion
- #region MonoBehaviour Callbacks
- private void Start()
- {
- SelectVSync();
- }
- #endregion
- #region Core
- #region VSync
- [InfoBox("SetVsync1 - Use ONLY when your game can maintain 60 fps. If not, use SetVsync0_60FPS or SetVsync0_120FPS, because your game will drop less frames then.\n" +
- "SetVsync2 - Use if you barely get 40 fps. It feels definitely better to have 30 consistent evenly spaced frames than 40 frames with varying delays between them.\n" +
- "SetVsync0_Default - Does whatever the platform does\n" +
- "SetVsync0_60FPS - Try this if you don't reach 60fps, it will look better than SetVsync1\n" +
- "SetVsync0_120FPS - Try this if you don't reach 60fps, it might look even better than SetVsync0_60FPS. It looks like less frames are dropped, i have no explanation, just try it yourself.\n" +
- "(Tested on Samsung phones, A3 2017, S6 edge+)\n")]
- [TabGroup("Values"), SerializeField] private VSyncMode vSync;
- private void SelectVSync()
- {
- switch (vSync)
- {
- case VSyncMode.VSync1:
- SetVsync1();
- break;
- case VSyncMode.VSync2:
- SetVsync2();
- break;
- case VSyncMode.VSync_Default:
- SetVsync0_Default();
- break;
- case VSyncMode.VSync0_60FPS:
- SetVsync0_60FPS();
- break;
- case VSyncMode.VSync0_120FPS:
- SetVsync0_120FPS();
- break;
- }
- }
- public void SetVsync1() { QualitySettings.vSyncCount = 1; Application.targetFrameRate = -1; }
- public void SetVsync2() { QualitySettings.vSyncCount = 2; Application.targetFrameRate = -1; }
- public void SetVsync0_Default() { QualitySettings.vSyncCount = 0; Application.targetFrameRate = -1; }
- public void SetVsync0_60FPS() { QualitySettings.vSyncCount = 0; Application.targetFrameRate = 60; }
- public void SetVsync0_120FPS() { QualitySettings.vSyncCount = 0; Application.targetFrameRate = 120; }
- public enum VSyncMode
- {
- VSync1,
- VSync2,
- VSync_Default,
- VSync0_60FPS,
- VSync0_120FPS
- }
- #endregion
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement