Author Topic: How to pass string with color to UIText List?  (Read 3213 times)

leegod

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
How to pass string with color to UIText List?
« on: August 13, 2014, 12:48:04 AM »
So I want to make message windows.

Messages will have various color as its sort (battle message, event message, etc), so I want to pass string with color info to UITextList

but UITextList seems only give .Add(str) function. So color should be "[FF0000]msg" like this.

Isn't there another way to pass color info? like, textlist.Add(str, colorpicker);


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to pass string with color to UIText List?
« Reply #1 on: August 13, 2014, 07:58:12 AM »
Add("[ff0000]" + yourtext)? :P

Also note NGUIText.EncodeColor.

Add("[" + NGUIText.EncodeColor(Color.red) + "]" + yourText);

leegod

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: How to pass string with color to UIText List?
« Reply #2 on: August 13, 2014, 09:24:06 PM »
Also note NGUIText.EncodeColor.

Add("[" + NGUIText.EncodeColor(Color.red) + "]" + yourText);

oh Good solution! Thank!