TMP_TextCanvasTypeSettings - jimdroberts/FishMMO GitHub Wiki

Description

The TMP_TextCanvasTypeSettings class is a canvas type settings handler for TextMeshPro's TMP_Text component in the FishMMO client. It applies color settings from a configuration file to TMP 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 TMP_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 TMP_TextCanvasTypeSettings is registered in your canvas settings map for TMP_Text components.
  2. Store color values (Primary, Text) in your configuration file.
  3. When ApplySettings is called, the TMP 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<TMP_Text>();
var settings = new TMP_TextCanvasTypeSettings();
settings.ApplySettings(text, configuration);

Best Practices

  • Use consistent naming conventions for TMP 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 TMP 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** ⚠️