Coloring individual characters in an NGUI UILabel text
For the game project that I'm currently working on, I needed to find an easy way to color individual characters in the text of an NGUI UILabel.
Fortunately, the solution is pretty simple. When the supportEncoding boolean field on a UILabel is set to true, the text supports color encoding in the[RRGGBB] format.
This means that we can have write text such as the following (the [-] is used to revert to a previous color):
[FF0000]Red[-] [00FF00]Green[-] [0000FF]Blue[-]
The reason I needed to do this was because we want the leading zeros in the Score UILabel to have a different colour than the actual score. And for that, I wrote this neat little method to format my current score to a string with a predefined number of leading zeros and then color those leading zeros independent from the main colour of the label text.
[출처] http://blog.dreasgrech.com/2013/05/coloring-individual-characters-in-ngui.html
'Unity3D > NGUI' 카테고리의 다른 글
NGUI Emoticons (0) | 2015.02.12 |
---|---|
NGUI UILabel로 Emoticon 넣기.. (0) | 2015.02.12 |
NGUI UILabel Reference (0) | 2014.12.31 |
NGUI UILabel BBCode (0) | 2014.12.31 |
PSD Layers to PNG Files(PSD2PNGs) (0) | 2014.12.31 |