ButtonCanvasTypeSettings - jimdroberts/FishMMO GitHub Wiki
The ButtonCanvasTypeSettings
class is a canvas type settings handler for Unity's Button
component in the FishMMO client. It applies color settings from a configuration file to the button's color states, enabling consistent theming and easy customization of UI button appearance.
-
public override void ApplySettings(object component, Configuration configuration)
Applies color settings from configuration to the given
Button
component. Sets the button's normal, pressed, highlighted, and selected colors using values parsed from the configuration.
- Ensure
ButtonCanvasTypeSettings
is registered in your canvas settings map forButton
components. - Store color values (Primary, Secondary, Highlight) in your configuration file.
- When
ApplySettings
is called, the button's color states will be updated according to the configuration.
// Example usage in a canvas crawler or theming system:
var button = myGameObject.GetComponent<Button>();
var settings = new ButtonCanvasTypeSettings();
settings.ApplySettings(button, configuration);
- Store all color values in a configuration file for easy theme changes.
- Use
ButtonCanvasTypeSettings
to centralize and automate button theming across your UI. - Register this handler in your canvas settings map to ensure all buttons are themed consistently.
- Extend or override for custom button behavior or additional color states if needed.
- Validate component types in
ApplySettings
to avoid runtime errors.