Pass ForgeDocs Product page

Scripting

Accessibility

An options menu that keeps its choices

PassForgeAccessibility.Save keeps the settings with PlayerPrefs, and they come back by themselves the next time the game starts. The Accessibility Menu component does all of it with no code.

using PassForge.Effects;
using UnityEngine;

// An options menu of your own for Pass Forge's accessibility settings. The Pass Forge Accessibility Menu component
// does all of this with no code. Hook each method to a Toggle, Slider or Dropdown.
public class AccessibilityOptions : MonoBehaviour
{
    public void SetSafeMode(bool on) => PassForgeAccessibility.safeMode = on;
    public void SetShake(float strength) => PassForgeAccessibility.shakeStrength = strength;   // 0 to 1
    public void SetFlash(float strength) => PassForgeAccessibility.flashStrength = strength;   // 0 to 1
    public void SetTextScale(float scale) => PassForgeAccessibility.textScale = scale;         // 1 to 2

    // Dropdown order: None, Protanopia, Deuteranopia, Tritanopia. Achromatopsia can only be simulated, so it is no choice here.
    public void SetColorBlindness(int index) => PassForgeAccessibility.colorBlindness = (ColorBlindness)index;

    // Dropdown order: Shown, Not Red, Off.
    public void SetBlood(int index) => PassForgeAccessibility.blood = (BloodSetting)index;

    // Saved with PlayerPrefs when the menu closes, not on every slider step; the choices come back by themselves
    // the next time the game starts.
    void OnDisable() => PassForgeAccessibility.Save();

    // A Cancel button: back to the choices last saved.
    public void Cancel() => PassForgeAccessibility.Load();
}