TextCanvasTypeSettings - jimdroberts/FishMMO GitHub Wiki
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.
-
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.
- Ensure
TextCanvasTypeSettings
is registered in your canvas settings map forText
components. - Store color values (Primary, Text) in your configuration file.
- When
ApplySettings
is called, the text's color will be set according to its name and the configuration.
// Example usage in a canvas crawler or theming system:
var text = myGameObject.GetComponent<Text>();
var settings = new TextCanvasTypeSettings();
settings.ApplySettings(text, configuration);
- 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.