Author Topic: Text color tags behave differently  (Read 4663 times)

Asse

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 70
    • View Profile
Text color tags behave differently
« on: November 27, 2013, 11:20:20 AM »
I've just upgrade from Unity 4.1.2 to 4.3 and from NGUI 2.7 to 3.0.6 and have noticed that colored text (e.g. [F7F6F6]my text here[-]) is now inked by the fonts default color. So if I have a text with black color and a white color tag, the text within the white color tag gets colored to black. You can check the behaviour within your Example 0, just change to color to black and the nice shiny yellow text gets black, too.

Now I've taken a look if the Unlit/Transparent Colored shader has changed and reverted it to an older version but the behaviour stays the same.

My question is, did Unity changed something within their shader pipeline? Did atlases use another shader before NGUI 3? Am I overworked and should go to bed?  ;)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Text color tags behave differently
« Reply #1 on: November 27, 2013, 11:30:29 AM »
This is intentional, and how it should have been. The label's tint color should affect everything, and color tags should blend the color, not change it outright. You can always leave your label white and then just add [000000] tag before your text to make it black like that if you want to be able to change it as you could before.

This wasn't a change on Unity's side but on NGUI's side as a part of the 3.X cycle.

Asse

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: Text color tags behave differently
« Reply #2 on: November 27, 2013, 12:13:34 PM »
Any ideas how I can change this behaviour quickly on my own?

Asse

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: Text color tags behave differently
« Reply #3 on: November 27, 2013, 01:49:24 PM »
Ok found it, I think it's a good idea to make the behaviour selectable.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Text color tags behave differently
« Reply #4 on: November 27, 2013, 02:12:21 PM »
I'm not sure the new way is a better way. Artists tend to want precise coloring, and when you mix them together, you don't have control, and you have to "wing it" to hit what you want. Ultimately, you're forced to just leave the tint white and always put in lots of [color codes].

N3uRo

  • Guest
Re: Text color tags behave differently
« Reply #5 on: November 27, 2013, 03:37:08 PM »
I'm not sure the new way is a better way. Artists tend to want precise coloring, and when you mix them together, you don't have control, and you have to "wing it" to hit what you want. Ultimately, you're forced to just leave the tint white and always put in lots of [color codes].

+1

avatara359

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 8
    • View Profile
Re: Text color tags behave differently
« Reply #6 on: May 27, 2014, 04:26:52 PM »
I'm not sure the new way is a better way. Artists tend to want precise coloring, and when you mix them together, you don't have control, and you have to "wing it" to hit what you want. Ultimately, you're forced to just leave the tint white and always put in lots of [color codes].

I agree precise coloring is preferred over blending. Blending still appears to be the current behavior. Unless your base color is white, you can't get a desired result like http://www.tasharen.com/ngui/step5final.jpg

What do I need to change to get precise coloring?

BeShifty

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 7
  • Posts: 52
    • View Profile
Re: Text color tags behave differently
« Reply #7 on: May 27, 2014, 05:52:32 PM »
As devil's advocate, you're removing the ability to fade that text in and out, as well as using any tweens, UIButtons, etc to tint those characters. Is that what you want?

avatara359

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 8
    • View Profile
Re: Text color tags behave differently
« Reply #8 on: May 27, 2014, 06:13:30 PM »
In this case, yes I want specific coloring of text that isn't tinted by the widget color. The base text color is blackish which completely eliminates the effect of the color tags. I was trying to color specific symbols red, I wasn't even getting a hint of red while using black text, the red only showed when I was using white for text color.

Anyway changed NGUIText.cs to what I wanted.
From:
                       
  1. if (encoding && ParseSymbol(text, ref i, mColors, premultiply, ref subscriptMode, ref bold, ref italic, ref underline, ref strikethrough))
  2.                         {
  3.                                 Color fc = tint * mColors[mColors.size - 1];
  4.                                 uc = fc;
  5.  
  6.                                 if (gradient)
  7.                                 {
  8.                                         gb = gradientBottom * fc;
  9.                                         gt = gradientTop * fc;
  10.                                 }
  11.                                 --i;
  12.                                 continue;
  13.                         }




To:
         
  1. if (encoding && ParseSymbol(text, ref i, mColors, premultiply, ref subscriptMode, ref bold, ref italic, ref underline, ref strikethrough))
  2.                         {
  3.                                 Color fc;
  4.                                 if( mColors.size == 1 )
  5.                                 {
  6.                                         fc = tint * mColors[mColors.size - 1];
  7.                                 }
  8.                                 else
  9.                                 {
  10.                                         fc = mColors[mColors.size - 1];
  11.                                         fc.a *= tint.a;
  12.                                 }
  13.                                 uc = fc;
  14.  
  15.                                 if (gradient)
  16.                                 {
  17.                                         gb = gradientBottom * fc;
  18.                                         gt = gradientTop * fc;
  19.                                 }
  20.                                 --i;
  21.                                 continue;
  22.                         }

I'm still grabbing the alpha from the tint so I can fade in/out but the color from the tag appears and I can still use a gradient.