修改设置界面

This commit is contained in:
bob
2025-05-29 18:03:24 +08:00
parent cdcb007d6d
commit f421288244
306 changed files with 41744 additions and 612 deletions

View File

@@ -0,0 +1,43 @@
using UnityEngine;
namespace Ilumisoft.GraphicsControl
{
/// <summary>
/// Default settings storage using PlayerPrefs. You can write your own storage class by extending the <see cref="GraphicSettingsStorage"/>
/// </summary>
[DisallowMultipleComponent()]
public class DefaultGraphicSettingsStorage : GraphicSettingsStorage
{
public override void SetFloat(string key, float value) => PlayerPrefs.SetFloat(key, value);
public override void SetInt(string key, int value) => PlayerPrefs.SetInt(key, value);
public override void SetString(string key, string value) => PlayerPrefs.SetString(key, value);
public override void SetBool(string key, bool value) => PlayerPrefs.SetInt(key, value ? 1 : 0);
public override float GetFloat(string key, float defaultValue) => PlayerPrefs.GetFloat(key, defaultValue);
public override int GetInt(string key, int defaultValue) => PlayerPrefs.GetInt(key, defaultValue);
public override string GetString(string key, string defaultValue) => PlayerPrefs.GetString(key, defaultValue);
public override bool GetBool(string key, bool defaultValue)
{
int value = PlayerPrefs.GetInt(key, defaultValue ? 1 : 0);
return value != 0;
}
private void OnDisable()
{
PlayerPrefs.Save();
}
private void OnApplicationFocus(bool focus)
{
if(!focus)
{
PlayerPrefs.Save();
}
}
private void OnApplicationPause(bool pause)
{
PlayerPrefs.Save();
}
}
}