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