ImageCanvasTypeSettings - jimdroberts/FishMMO GitHub Wiki
The ImageCanvasTypeSettings
class is a canvas type settings handler for Unity's Image
component in the FishMMO client. It applies color settings from a configuration file to image components, supporting theming for backgrounds, crosshairs, health/mana/stamina bars, and other UI images based on their names or sprite names.
-
public override void ApplySettings(object component, Configuration configuration)
Applies color settings from configuration to the given
Image
component. Uses naming conventions to determine which color to apply (e.g., Primary, Crosshair, Health, Mana, Stamina).
- Ensure
ImageCanvasTypeSettings
is registered in your canvas settings map forImage
components. - Store color values (Primary, Crosshair, Health, Mana, Stamina) in your configuration file.
- When
ApplySettings
is called, the image's color will be set according to its name or sprite name and the configuration.
// Example usage in a canvas crawler or theming system:
var image = myGameObject.GetComponent<Image>();
var settings = new ImageCanvasTypeSettings();
settings.ApplySettings(image, configuration);
- Use consistent naming conventions for images and sprites to enable automatic theming.
- Store all color values in a configuration file for easy theme changes.
- Register this handler in your canvas settings map to ensure all images are themed consistently.
- Extend or override for custom image behavior or additional color logic if needed.
- Validate component types in
ApplySettings
to avoid runtime errors.