inline images, or icons as text characters (shortcodes/merge tags)

I am trying to set up a system where I can put icons inline with text like the tooltip below from Age of Wonders 3, where a resource amount is often followed by the resource’s icon. I come from web development so some way to do inline images or a way to parse through your strings and replace merge tags or shortcodes with the icon is what I’m looking for (example string for a unit’s health: “14/35{%HP_ICON%}” and it runs thru a parse function that matches {%TAGS%} to a resource path).

I notice the rich text option for text objects but it only seems to allow very very basic markup, nothing like images.

Depending how far you are into your project, you can switch to using TextMesh Pro which includes support for inline graphics. You can either use the tag to reference some sprite in a Sprite Asset or assign some Unicode value to those sprites and use UTF16 \u0000 with 2 hex pairs or use UTF32 \UFF00FF00 with 4 hex pairs.

See the following video which is a bit old now but it will give you a good overview of the sprite tag.

Here is an example where the sprite is referenced by name. Raw text is “You gain 5 HP!”

6 Likes

If for any reason you didn’t want to switch to TMP (but it’s awesome…:)), if the text is well structured, as in the sprites won’t be at random locations, you could have a layout group, I think.
It may not be as good, but from the photo you provided, that scenario looks possible.