Fade rich text with <color> tags.

Hi,
any ideas how to fade rich text when we use “<color=green> text ” tags?
Maybe somehow by using hexadecimal digits “<color=#008000ff> text ”?

In this case “GUI.color.a” doesn’t work and i understand why, but i can’t figure out how to fade with color tags :confused:

1 Like

I suppose you could try to fade by going from <color=#008000ff> to <color=#00800000> (I haven’t tested this), but setting the GUI style’s alpha value should work. Use a custom GUIStyle (e.g., GUIStyle myGuiStyle = new GUIStyle(GUI.skin.label)) and change myGuiStyle.normal.textColor.a. You want to change the alpha of the text color, not the background color.

Like this? (see webplayer) :wink:

That’s a nudge-wink that if you buy the asset you can see how it is done. Sorry, i couldn’t be any more helpful :face_with_spiral_eyes:, but it wasn’t a simple task.

You can use material on the Text object to do it.
Create material, set shader to GUI/Text shader
Then you can modify it like that: GetComponent().material.color = new Color(1,1,1,a);

1 Like

You can use CanvasRenderer.SetAlpha, best way to fade UI…

The OP was asking about legacy Unity GUI. (This is the legacy GUI forum. ;))

For Unity UI, I agree that changing alpha (e.g., CanvasGroup.alpha or Text.color.alpha) is the way to go. You can even control it in an animation clip so you don’t need to write any code.

Ooo sorry, found this on google, I had troubles with rich text color and using text.color to fade (had no effect on color tagged part of text), but CanvasRenderer.SetAlpha works nice

1 Like

Thanks a lot! Your reply is helpful to me. From China Shanghai.

1 Like

I think it must be a bug. Mechanim is fine to fade text with alpha, but not when it has color tags.