Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: sk1989 on September 06, 2012, 01:20:08 PM

Title: Changing colors of individual chars within a string
Post by: sk1989 on September 06, 2012, 01:20:08 PM
Hello,

I was wondering if there is a way for you to write a code or some sort of key that will allow you to change individual chars within a longer string?

For example: If 1 long string contains 2 words and I want the first word to be white and the second word to be red.
                  string =  Hello(white) World(red)

Is it possible to do this? Or would I have to make 2 separate labels, each of which having a different color tint to it?

thank you

Title: Re: Changing colors of individual chars within a string
Post by: ryan on September 06, 2012, 01:55:00 PM
[ffffff]Hello[-] [ff0000]World[-]

Assuming encoding is enabled for your label (there's a checkbox in the inspector), you can put a hexadecimal RGB value within square brackets to change the color of a string within the label.  A dash within square brackets clears the color back to the default for the label.