TMP_InputFieldCanvasTypeSettings - jimdroberts/FishMMO GitHub Wiki
The TMP_InputFieldCanvasTypeSettings
class is a canvas type settings handler for TextMeshPro's TMP_InputField
component in the FishMMO client. It applies color settings from a configuration file to the input field's color states, enabling consistent theming and easy customization of TMP input field appearance.
-
public override void ApplySettings(object component, Configuration configuration)
Applies color settings from configuration to the given
TMP_InputField
component. Sets the input field's normal, pressed, highlighted, and selected colors using values parsed from the configuration.
- Ensure
TMP_InputFieldCanvasTypeSettings
is registered in your canvas settings map forTMP_InputField
components. - Store color values (Primary, Secondary, Highlight) in your configuration file.
- When
ApplySettings
is called, the input field's color states will be updated according to the configuration.
// Example usage in a canvas crawler or theming system:
var inputField = myGameObject.GetComponent<TMP_InputField>();
var settings = new TMP_InputFieldCanvasTypeSettings();
settings.ApplySettings(inputField, configuration);
- Store all color values in a configuration file for easy theme changes.
- Use
TMP_InputFieldCanvasTypeSettings
to centralize and automate TMP input field theming across your UI. - Register this handler in your canvas settings map to ensure all TMP input fields are themed consistently.
- Extend or override for custom input field behavior or additional color states if needed.
- Validate component types in
ApplySettings
to avoid runtime errors.