BrightnessSettingOption - jimdroberts/FishMMO GitHub Wiki
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.
-
public Slider BrightnessSlider
The slider UI component for adjusting brightness.
-
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.
- Attach
BrightnessSettingOption
to a brightness option UI GameObject in the Unity Editor. - Assign the
BrightnessSlider
field in the Inspector. - Ensure the configuration system is available and properly set up.
// Example usage in a MonoBehaviour
public BrightnessSettingOption brightnessOption;
void Start() {
brightnessOption.Initialize();
brightnessOption.Load();
}
// When the slider value changes, Save() is called automatically.
- 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.