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