- Home /
Modify individual letters in new Unity UI Text
Is it at all possible to change the properties (or at least, the color) of an individual character of the new Unity UI text component, without changing the other letters? I'd like to fade in a string letter by letter, and the string text changes so I can't really just make a whole bunch of individual text fields per letter.
Or failing that, is it possible to get the properties of any given letter (the letter's X position, Y position, width, and height)? That way I could create the whole string then use that data to split it up into individual Text components at runtime.
Thanks for any insight!
Answer by CanisLupus · Nov 26, 2014 at 09:17 PM
Somewhat. As long as the Rich Text checkbox is activated in the Text component, you can use a few supported tags, similar to HTML. Using the color
tag, for example, you can color parts of your text (or a single character, as you require). See this link for a description of all the options and how to use color. (I tried to place an example in this answer, but Unity Answers doesn't work well with tags, so I gave up.)
You require fading in each letter at a time. The color tag accepts alpha; just remember that you'll have to change the string you're displaying every frame for this (if this is a problem, performance-wise, that depends on the text size and your exact approach). You might want to use the StringBuilder class.
I don't think you have access to the meshes of individual characters, so getting the position and size of characters in the text might be impossible, but my knowledge on that topic is limited :)
Your answer
Follow this Question
Related Questions
How to change color of text relative to current color? 1 Answer
How do I color exactly half of a word in TMPro UI text? 0 Answers
UI Text.color not assigning? 2 Answers
How to make a "Click to Continue" text message? 1 Answer
Gradient Text in Unity 5.2.2 "BaseVertexEffect is obsolete use BaseMeshEffect instead" 3 Answers