Files
zeling_v2/Assets/_Game/Scripts/Support/Accessibility/AccessibilitySettingsSO.cs
T

50 lines
2.3 KiB
C#

using UnityEngine;
using BaseGames.Core.Events;
namespace BaseGames.Support.Accessibility
{
/// <summary>
/// 无障碍设置数据 SO(架构 16_SupportingModules §6)。
/// 包含屏幕抖动、闪光减弱、色盲模式等辅助功能开关。
/// </summary>
[CreateAssetMenu(menuName = "BaseGames/Settings/AccessibilitySettings", fileName = "SET_Accessibility")]
public class AccessibilitySettingsSO : ScriptableObject
{
private const string PrefsPrefix = "accessibility_";
[Header("屏幕体感")]
public bool ScreenShake = true;
public bool ReducedFlash = false;
[Header("色盲模式")]
public ColorblindMode ColorblindMode = ColorblindMode.None;
[Header("文字与 UI")]
public bool LargeText = false;
public bool HighContrast = false;
public float UIScale = 1f;
// ── 持久化 ──────────────────────────────────────────────────────────────
public void Save()
{
PlayerPrefs.SetInt (PrefsPrefix + "ScreenShake", ScreenShake ? 1 : 0);
PlayerPrefs.SetInt (PrefsPrefix + "ReducedFlash", ReducedFlash ? 1 : 0);
PlayerPrefs.SetInt (PrefsPrefix + "ColorblindMode",(int)ColorblindMode);
PlayerPrefs.SetInt (PrefsPrefix + "LargeText", LargeText ? 1 : 0);
PlayerPrefs.SetInt (PrefsPrefix + "HighContrast", HighContrast ? 1 : 0);
PlayerPrefs.SetFloat (PrefsPrefix + "UIScale", UIScale);
PlayerPrefs.Save();
}
public void Load()
{
ScreenShake = PlayerPrefs.GetInt (PrefsPrefix + "ScreenShake", 1) == 1;
ReducedFlash = PlayerPrefs.GetInt (PrefsPrefix + "ReducedFlash", 0) == 1;
ColorblindMode = (ColorblindMode)PlayerPrefs.GetInt(PrefsPrefix + "ColorblindMode", 0);
LargeText = PlayerPrefs.GetInt (PrefsPrefix + "LargeText", 0) == 1;
HighContrast = PlayerPrefs.GetInt (PrefsPrefix + "HighContrast", 0) == 1;
UIScale = PlayerPrefs.GetFloat(PrefsPrefix + "UIScale", 1f);
}
}
}