ImageCanvasTypeSettings - jimdroberts/FishMMO GitHub Wiki

Description

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.


API Access

Methods

  • 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).


Basic Usage

Setup

  1. Ensure ImageCanvasTypeSettings is registered in your canvas settings map for Image components.
  2. Store color values (Primary, Crosshair, Health, Mana, Stamina) in your configuration file.
  3. When ApplySettings is called, the image's color will be set according to its name or sprite name and the configuration.

Example

// Example usage in a canvas crawler or theming system:
var image = myGameObject.GetComponent<Image>();
var settings = new ImageCanvasTypeSettings();
settings.ApplySettings(image, configuration);

Best Practices

  • 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.
⚠️ **GitHub.com Fallback** ⚠️