BrightnessSettingOption - jimdroberts/FishMMO GitHub Wiki

Description

A UI option for adjusting the screen brightness in the FishMMO client. Provides a slider for users to change brightness, persists the setting, and updates the ambient light in real time. Integrates with the configuration system and Unity's rendering settings.


API Access

Fields

  • public Slider BrightnessSlider

    The slider UI component for adjusting brightness.

Methods

  • public override void Initialize()

    Initializes the brightness setting, sets up listeners, and validates required fields. Logs an error if the slider is missing.

  • public override void Load()

    Loads the brightness value from configuration and updates the UI and ambient light. Defaults to 1.0f if not set.

  • public override void Save()

    Saves the current brightness value to configuration and updates ambient light.


Basic Usage

Setup

  1. Attach BrightnessSettingOption to a brightness option UI GameObject in the Unity Editor.
  2. Assign the BrightnessSlider field in the Inspector.
  3. Ensure the configuration system is available and properly set up.

Example

// Example usage in a MonoBehaviour
public BrightnessSettingOption brightnessOption;

void Start() {
    brightnessOption.Initialize();
    brightnessOption.Load();
}

// When the slider value changes, Save() is called automatically.

Best Practices

  • Always assign the BrightnessSlider in the Inspector to avoid errors.
  • Use the configuration system to persist user preferences.
  • Update ambient light immediately for responsive feedback.
  • Validate required fields and log errors for missing references.
⚠️ **GitHub.com Fallback** ⚠️