UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Ui Module / TMP CapsLock System Completed

Ui Module — UGTK

TMP Caps Lock

Summary

Three small components that force the letter casing of a TextMeshPro label or input field, so the casing rule lives on the object instead of being sprinkled through the code that writes the text:

They all work in Play Mode and in the editor, so what you see while designing is what ships.


Content


Modules Dependencies

None on the UGTK side. It requires TextMesh Pro (TMPro).


Setup

Drop one of the three prefabs under a CanvasText_Caps_On, Text_Caps_Off or Text First Letter Upper Case, each a TMP label with the matching component already attached:

Or add the component you need to a GameObject that already has a TMP_Text — it also works when the text is the child of a TMP_InputField.


How To Use

Mn_TMPCapsOn / Mn_TMPCapsOff

Attach and forget: the label is kept ToUpperInvariant() / ToLowerInvariant() in LateUpdate, so whatever writes the text — a localization system, a typewriter, a score counter — the casing holds.

They use the invariant culture: no Turkish dotted/dotless i surprise, and no locale-dependent behaviour between editor and device.

TMPMn__FirstLetterUppercase

Capitalizes the first non-whitespace character and leaves the rest of the string alone — the right rule for a player name, a city, a free-text answer.

Note the class name: the script file is Mn_TMPFirstLetterUppercase.cs but the class inside is TMPMn__FirstLetterUppercase — use that name in GetComponent<>().

capsComponent.ApplyNow();   // force the transform from code or from the inspector

Good to know:


Testing Scene

Open Debug/TMPCapsLock.unity: the three cases sit side by side — a forced-uppercase label, a forced-lowercase one, and an input field that capitalizes the first letter while you type.


Technical Info

Path Content
Scripts/Mn_TMPCapsOn.cs Forces ToUpperInvariant() on the TMP label
Scripts/Mn_TMPCapsOff.cs Forces ToLowerInvariant() on the TMP label
Scripts/Mn_TMPFirstLetterUppercase.cs TMPMn__FirstLetterUppercase: capitalizes the first non-space character on TMP_Text or TMP_InputField, wiring onValueChanged / onEndEdit and restoring caret and selection
Prefabs/Text_Caps_On.prefab TMP label, uppercase
Prefabs/Text_Caps_Off.prefab TMP label, lowercase
Prefabs/Text First Letter Upper Case.prefab TMP label with first-letter capitalization
Debug/TMPCapsLock.unity Test scene with the three cases

© 2026 Marcello De Bonis. All rights reserved