| | |
| | | const string SOUND_VOLUME_KEY = "SoundRatioKey"; //音乐
|
| | | const string SOUND_EFFECT_KEY = "SoundEffect"; //音效
|
| | | const string FPS_KEY = "FPSKey";
|
| | | const string VSYNC_KEY = "GameVSyncCountSetting";//垂直同步率
|
| | | const string GAMEFRAME_KEY = "GameFrameSetting";//垂直同步率
|
| | |
|
| | | public Dictionary<SystemSwitch, bool> systemSettings = new Dictionary<SystemSwitch, bool>();
|
| | |
|
| | |
| | | public event Action<SystemSwitch, bool> OnSettingChanged;
|
| | | public event Action qualityLevelChangeEvent;
|
| | | public event Action playerSyncCountChangeEvent;
|
| | | public event Action vSyncCountChangeEvent;
|
| | | public event Action gameFrameChangeEvent;
|
| | |
|
| | | public SystemSetting()
|
| | | {
|
| | |
| | | return LocalSave.GetFloat(SOUND_EFFECT_KEY, 1);
|
| | | }
|
| | |
|
| | | public void SetVSyncCount(int _vSync)
|
| | | public void SetGameFrame(GameFrame _frame)
|
| | | {
|
| | | LocalSave.SetInt(VSYNC_KEY, QualitySettings.vSyncCount = Mathf.Clamp(_vSync, 0, 2));
|
| | |
|
| | | if (vSyncCountChangeEvent != null)
|
| | | LocalSave.SetInt(GAMEFRAME_KEY, (int)_frame);
|
| | | switch (_frame)
|
| | | {
|
| | | vSyncCountChangeEvent();
|
| | | case GameFrame.FullFrame:
|
| | | SetFPSLimit(60);
|
| | | break;
|
| | | case GameFrame.HalfFrame:
|
| | | SetFPSLimit(30);
|
| | | break;
|
| | | }
|
| | |
|
| | | if (gameFrameChangeEvent != null)
|
| | | {
|
| | | gameFrameChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public int GetVSyncCount()
|
| | | public GameFrame GetGameFrame()
|
| | | {
|
| | | return LocalSave.GetInt(VSYNC_KEY, 2);
|
| | | return (GameFrame)LocalSave.GetInt(GAMEFRAME_KEY, (int)GameFrame.HalfFrame);
|
| | | }
|
| | |
|
| | | public void SetSystemSettingSwitch(SystemSwitch type, bool _value)
|
| | |
| | |
|
| | | public void SetFPSLimit(int _fps)
|
| | | {
|
| | | LocalSave.SetInt(FPS_KEY, Application.targetFrameRate = Mathf.Clamp(_fps, 30, 60));
|
| | | Application.targetFrameRate = Mathf.Clamp(_fps, 30, 60);
|
| | | }
|
| | |
|
| | | public int GetFPSLimit()
|
| | | {
|
| | | return LocalSave.GetInt(FPS_KEY, 30);
|
| | | switch (GetGameFrame())
|
| | | {
|
| | | case GameFrame.HalfFrame:
|
| | | return 30;
|
| | | case GameFrame.FullFrame:
|
| | | return 60;
|
| | | default:
|
| | | return 30;
|
| | | }
|
| | | }
|
| | |
|
| | | public void LetFPSUnLimit()
|
| | |
| | | Low = 0,
|
| | | Medium = 1,
|
| | | High = 2,
|
| | | }
|
| | |
|
| | | public enum GameFrame
|
| | | {
|
| | | Free = 0,
|
| | | HalfFrame = 1,
|
| | | FullFrame = 2,
|
| | | } |