UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Ui Module / TMP Partial Bold Completed

Ui Module — UGTK

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

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:


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:

  1. Bold a word in the middle of a sentence and check the spacing around it.
  2. Bold a word containing an accented character.
  3. Bold across a line break.
  4. 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

Real dependenciesOpen in the map →

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.