UIOptions - jimdroberts/FishMMO GitHub Wiki
A UI controller for managing all setting options in the FishMMO client. Handles initialization, loading, and saving of all child SettingOption
components, and manages the global configuration lifecycle. Ensures that all settings are properly loaded and saved when the UI is started or destroyed.
-
private List settingOptions
List of all setting options found in child objects.
-
public override void OnStarting()
Called when the UI is starting. Loads configuration and initializes all setting options. If configuration fails to load, sets defaults and saves a new file.
-
public void LoadAll()
Loads all setting options from configuration.
-
public void SaveAll()
Saves all setting options to configuration and persists the global settings file.
-
public override void OnDestroying()
Called when the UI is being destroyed. (No implementation)
- Attach
UIOptions
to a parent UI GameObject containing childSettingOption
components. - Ensure the configuration system is available and properly set up.
- Call
OnStarting()
to initialize and load all settings.
// Example usage in a MonoBehaviour
public UIOptions uiOptions;
void Start() {
uiOptions.OnStarting();
}
// To reload all settings
uiOptions.LoadAll();
// To save all settings
uiOptions.SaveAll();
- Ensure all child setting controls inherit from
SettingOption
for automatic management. - Always call
OnStarting()
to initialize and load settings when the UI is shown. - Use
LoadAll()
andSaveAll()
to synchronize settings with configuration as needed. - Handle configuration file errors gracefully and provide defaults if loading fails.