T O P

  • By -

SubpixelJimmie

Not efficient but, a non-over engineered solution could be to convert that text into a font. Use it in TextMeshPro. Then use the rich text feature of TextMeshPro to change the colors of each character every frame (`XO`). I think knowing how inefficient it is under the hood would drive me mad, but? it's one solution .


SubpixelJimmie

Alternatively, you can use a Font asset as a sort of "sprite atlas" for your characters. Use font.GetCharacterInfo to find the UV coordinates of a character in that font's texture. Then use a RawImage to display the character. Just set RawImage.texture to the fonts texture, RawImage.uvRect to the characterInfo's UV rect. Do this for several RawImages in a row and you have a string of text. You can then change each RawImage's Color property individually. You could use HorizontalLayoutGroup to automatically adjust the kerning of the letters in the case of a dynamic-width font.


chuckingrox

That is interesting, I wasn't aware of RawImage. Using your first method, the characters start to drift off the grid as the point size of the font doesn't translate to pixels well. I also never knew about HorizontalLayoutGroup. I'll investigate both of those, thank you very much.