RefreshRateSettingOption - jimdroberts/FishMMO GitHub Wiki
A UI option for adjusting the screen refresh rate in the FishMMO client. Provides a dropdown for users to select the desired refresh rate, persists the setting, and applies it to the game window. Integrates with the configuration system and Unity's screen settings.
-
public TMP_Dropdown RefreshRateDropdown
The dropdown UI component for selecting screen refresh rate.
-
public override void Initialize()
Initializes the refresh rate setting, sets up listeners, and populates available refresh rates. Logs an error if the dropdown is missing.
-
private void PopulateRefreshRates()
Populates the dropdown with all available refresh rates for the current resolution and sets the current selection.
-
public override void Load()
Loads the saved refresh rate from configuration and applies it. Defaults to 60Hz if not set.
-
public override void Save()
Saves the selected refresh rate to configuration and applies it.
-
private void ApplyRefreshRate(RefreshRate refreshRate)
Applies the given refresh rate to the screen for the current resolution.
- Attach
RefreshRateSettingOption
to a refresh rate option UI GameObject in the Unity Editor. - Assign the
RefreshRateDropdown
field in the Inspector. - Ensure the configuration system is available and properly set up.
// Example usage in a MonoBehaviour
public RefreshRateSettingOption refreshRateOption;
void Start() {
refreshRateOption.Initialize();
refreshRateOption.Load();
}
// When the dropdown value changes, Save() is called automatically.
- Always assign the
RefreshRateDropdown
in the Inspector to avoid errors. - Use the configuration system to persist user preferences.
- Populate the dropdown with only supported refresh rates for the current resolution.
- Validate required fields and log errors for missing references.