| | |
| | | const string QUALITY_LEVEL_KEY = "GameQualityLevel";
|
| | | const string SOUND_VOLUME_KEY = "SoundRatioKey"; //音乐
|
| | | const string SOUND_EFFECT_KEY = "SoundEffect"; //音效
|
| | | const string FPS_KEY = "FPSKey";
|
| | | 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 gameFrameChangeEvent;
|
| | |
|
| | | public SystemSetting()
|
| | | {
|
| | |
| | | public float GetSoundEffect()
|
| | | {
|
| | | return LocalSave.GetFloat(SOUND_EFFECT_KEY, 1);
|
| | | }
|
| | |
|
| | | public void SetGameFps(GameFps _frame)
|
| | | {
|
| | | LocalSave.SetInt(GAMEFRAME_KEY, (int)_frame);
|
| | | SetFPSLimit((int)_frame);
|
| | | if (gameFrameChangeEvent != null)
|
| | | {
|
| | | gameFrameChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public GameFps GetGameFps()
|
| | | {
|
| | | return (GameFps)LocalSave.GetInt(GAMEFRAME_KEY, (int)GameFps.Full);
|
| | | }
|
| | |
|
| | | public void SetSystemSettingSwitch(SystemSwitch type, bool _value)
|
| | |
| | | public void SetQualityLevel(GameQuality _quality, bool _disabeCamera = true)
|
| | | {
|
| | | LocalSave.SetInt(QUALITY_LEVEL_KEY, Mathf.Clamp((int)_quality, 0, 2));
|
| | | QualitySettings.SetQualityLevel((int)GameQuality.High);
|
| | |
|
| | | QualitySettings.SetQualityLevel(Mathf.Clamp((int)_quality, 0, 2));
|
| | | switch (_quality)
|
| | | {
|
| | | case GameQuality.Low:
|
| | |
| | | Shader.DisableKeyword("QUALITY_HGH");
|
| | | Shader.DisableKeyword("QUALITY_MED");
|
| | | Shader.EnableKeyword("QUALITY_LOW");
|
| | | PostProcessingUtility.TogglePostProcessing(false);
|
| | | break;
|
| | | case GameQuality.Medium:
|
| | | Shader.globalMaximumLOD = 250;
|
| | | Shader.DisableKeyword("QUALITY_HGH");
|
| | | Shader.EnableKeyword("QUALITY_MED");
|
| | | Shader.DisableKeyword("QUALITY_LOW");
|
| | | PostProcessingUtility.TogglePostProcessing(false);
|
| | | break;
|
| | | case GameQuality.High:
|
| | | Shader.globalMaximumLOD = 500;
|
| | | Shader.EnableKeyword("QUALITY_HGH");
|
| | | Shader.DisableKeyword("QUALITY_MED");
|
| | | Shader.DisableKeyword("QUALITY_LOW");
|
| | | PostProcessingUtility.TogglePostProcessing(false);
|
| | | break;
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | var defaultQuality = GameQuality.High;
|
| | |
|
| | | if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 3.5f * 1024)
|
| | | {
|
| | | defaultQuality = GameQuality.High;
|
| | | }
|
| | | else if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 2.5f * 1024)
|
| | | {
|
| | | defaultQuality = GameQuality.Medium; ;
|
| | | }
|
| | | else if (DeviceUtility.cpu > 1 && DeviceUtility.memory > 1.5f * 1024)
|
| | | {
|
| | | defaultQuality = GameQuality.Low;
|
| | | }
|
| | | // if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 3.5f * 1024)
|
| | | // {
|
| | | // defaultQuality = GameQuality.High;
|
| | | // }
|
| | | // else if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 2.5f * 1024)
|
| | | // {
|
| | | // defaultQuality = GameQuality.Medium; ;
|
| | | // }
|
| | | // else if (DeviceUtility.cpu > 1 && DeviceUtility.memory > 1.5f * 1024)
|
| | | // {
|
| | | // defaultQuality = GameQuality.Low;
|
| | | // }
|
| | |
|
| | | return (GameQuality)LocalSave.GetInt(QUALITY_LEVEL_KEY, (int)defaultQuality);
|
| | | }
|
| | |
| | |
|
| | | 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);
|
| | | return (int)GetGameFps();
|
| | | }
|
| | |
|
| | | public void LetFPSUnLimit()
|
| | |
| | | {
|
| | | systemSettings.Clear();
|
| | | m_PlayerSyncCount = -1;
|
| | | }
|
| | |
|
| | | private GameFps GetRecommendFps()
|
| | | {
|
| | | if (Screen.width * Screen.height > (1920 * 1080 + 10000))
|
| | | {
|
| | | return GameFps.Half;
|
| | | }
|
| | | else
|
| | | {
|
| | | return GameFps.Full;
|
| | | }
|
| | | }
|
| | |
|
| | | IEnumerator Co_WaitFewMinute()
|
| | |
| | | Low = 0,
|
| | | Medium = 1,
|
| | | High = 2,
|
| | | }
|
| | |
|
| | | public enum GameFps
|
| | | {
|
| | | Free = -1,
|
| | | Half = 30,
|
| | | Full = 60,
|
| | | } |