UGTK / Toolkit / Ui Module / TMP Partial Bold Completed
TMP Partial Bold
Summary
The TMP Partial Bold system puts bold on selected parts of a TextMeshProUGUI label without
making designers write rich text by hand. The source can be a marked string (**bold**) or an
ordered list of segments, each with its own bold flag; the component generates the <b>…</b> markup
and writes it into the label — in Play Mode and in the editor, thanks to [ExecuteAlways].
It exists because a localized string with a couple of emphasised words is a pain to keep in sync when the rich text lives in the label: here the text stays readable and the markup is generated.
Content
Modules Dependencies
TextMeshPro (com.unity.textmeshpro). No UGTK dependency.
Setup
Drop the Text Partial Bold (TMP) prefab under a Canvas — a TMP label with
Mn_TMPPartialBoldText already attached and a sample marked string:
Or add Mn_TMPPartialBoldText to a GameObject that already has a TextMeshProUGUI: the component
is [RequireComponent(typeof(TextMeshProUGUI))] and [DisallowMultipleComponent], and it picks the
label up by itself.
How To Use
Input Mode
- MarkedString (default): type plain text in Marked Text and wrap the bold parts in the
marker:
Tap the **Best Practice** icons to score points. This is the mode to hand to a translator: the marker travels with the string. - Segments: fill the Segments list, each entry with its own text and bold toggle. Use it when the pieces come from different sources (a name, a number, a fixed label).
Markup
- Bold Marker (default **): change it if ** can appear in your copy — for example to __.
- Parse Markers Inside Segments (default on): a segment that contains the marker is parsed as a
marked string. Careful: in that case the segment's own bold flag is ignored — the markers
win.
Auto - Apply On Enable / Apply On Validate (both on): the label rebuilds when the object is enabled and whenever a field changes in the inspector, which is what makes editing live.
Debug - Last Applied Rich Text is a read-only view of the string that was written into the label: the fastest way to check the generated markup.
partialBold.SetMarkedText("Score **1200** points"); // switches to MarkedString and applies
partialBold.SetSegments( // switches to Segments and applies
new S_TMPTextSegment("Player: "),
new S_TMPTextSegment(playerName, bold: true));
string preview = partialBold.BuildRichText(); // builds without touching the label
// static, usable anywhere without a component
string rich = Mn_TMPPartialBoldText.BuildFromMarkedString("Tap the **icons**");
Good to know:
- An unmatched marker is left alone.
Tap the **iconsrenders as literal**icons, not as bold to the end of the string: a broken translation degrades gracefully. - The component forces
richText = trueon the label; it cannot work with rich text disabled. - Only bold is generated. Any other TMP tag you type survives — the builder copies it through —
but the marker only ever produces
<b>…</b>. Apply()skips the write when the generated string has not changed, so leaving Apply On Validate on costs nothing.
Testing Scene
This module has no Debug scene yet. Build a minimal one — a canvas with a few TMP labels using the component — and keep it
in Debug/, so the behaviour below can be checked the same way every time.
What to do, in order:
- Bold a word in the middle of a sentence and check the spacing around it.
- Bold a word containing an accented character.
- Bold across a line break.
- Use a font asset that has no bold variant.
Step 4 is the one that produces the confusing result: without a real bold face TMP fakes the weight, and the faked version is noticeably worse — uneven and slightly blurry. If the bold looks wrong, look at the font asset before the component.
Scene and GIF still to make.
Technical Info
| Path | Content |
|---|---|
Scripts/Runtime/Mn_TMPPartialBoldText.cs |
The component: the two input modes, Apply(), and the static builders BuildFromMarkedString / BuildFromSegments |
Scripts/Runtime/S_TMPTextSegment.cs |
Serializable struct: text + bold |
Scripts/Editor/Mn_TMPPartialBoldText_Editor.cs |
Custom inspector: help box and Apply Rich Text button |
Prefabs/Text Partial Bold (TMP).prefab |
Sample TMP label with the component |
Mn_TMPPartialBoldText API: Apply(), SetMarkedText(string), SetSegments(...),
BuildRichText(), BuildFromMarkedString(string, string) (static),
BuildFromSegments(IReadOnlyList<S_TMPTextSegment>, bool, string) (static).
InputMode: Segments / MarkedString.
© 2026 Marcello De Bonis. All rights reserved
Depends on 1
Used by 0
- No other module depends on it.
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 1 module in total.
UGTKengine within an engine


