TextCanvasTypeSettings - jimdroberts/FishMMO GitHub Wiki

Description

The TextCanvasTypeSettings class is a canvas type settings handler for Unity's Text component in the FishMMO client. It applies color settings from a configuration file to text components, supporting theming for placeholder and regular text based on the object's name.


API Access

Methods

  • public override void ApplySettings(object component, Configuration configuration)

    Applies color settings from configuration to the given Text component. Uses the primary color for placeholders and the text color for regular text, based on the object's name.


Basic Usage

Setup

  1. Ensure TextCanvasTypeSettings is registered in your canvas settings map for Text components.
  2. Store color values (Primary, Text) in your configuration file.
  3. When ApplySettings is called, the text's color will be set according to its name and the configuration.

Example

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

Best Practices

  • Use consistent naming conventions for text objects 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 text components are themed consistently.
  • Extend or override for custom text behavior or additional color logic if needed.
  • Validate component types in ApplySettings to avoid runtime errors.
⚠️ **GitHub.com Fallback** ⚠️