I want to make similar effect we had in DF GUI, where text color can be gradient. I’m using custom material with build-in UI/Text shader, changing it to something like this:
half4 frag (v2f i) : COLOR
{
half4 col = i.color;
col.a *= tex2D(_MainTex, i.texcoord).a;
col = col * _Color * tex2D(_MainTex, i.texcoord);
clip (col.a - 0.01);
return col;
}
where in “_MainTex” I assign gradient texture.
I expect color multiply by gradient, but all I get is grey text all the time.
Vertex Color Gradient & Animation
This video provides a short overview of TextMesh Pro as well as showing the latest implementation of support for Vertex Color Gradients in TextMesh Pro in Unity 4.6 & UI.
Note that you will be able to animate the (4) vertex colors independently of each other using Unity’s Animation component.
I’ve just realized that I can’t animate color values on this Gradient. Do you have any suggestions for that? I suppose I could create a script “bridge” to animate them…
I created the script bridge to animate the color, but I had to do something else too. The UI apparently doesn’t update if it doesn’t know it has to, so even if you change the value of the gradient colors by script, you still need to sort of “poke” the UI to make them actually change. I did this by setting the text.color to a random value (since it gets overwritten by the Gradient component anyway).
I thought I should post this for anyone else who may encounter the same issue.
I found nice solution but honestly i will create PRO (paid) pack of my extension for few $ mainly aiming on animation support (because most of my extension doesnt support animation or support very dirty)…
Just to tease a little bit as this is just a first implementation
In this video you can see the Vertex Color Gradient on the text combined with the bevel, soft shadow and the new Animated Overlay FX.
In this short GIF animation you can see how we are combining vertex color gradient, outline, bevel, soft shadows, overlay FX and bump mapping on the face of the TextMesh Pro text object.
The font is Impact SDF with some bevel, soft shadow, gradient vertex color and some bump mapping and of course an Animated Overlay EnvMap.
I had the same issue, which the new script resolves, however I struggled to get a local vertical gradient (for multi line text elements). To fix I used these lines:
case GradientDir.Vertical:
if(i % 2 == 0)
uiVertex.color *= (i % 3 == 0 || (i - 0) % 3 == 0) ? vertex1 : vertex2;
else
uiVertex.color *= (i % 3 == 0 || (i - 0) % 3 == 0) ? vertex2 : vertex1;
break;
“Assets/Script/UI/Effects/Gradient.cs(7,14): error CS0534: Gradient' does not implement inherited abstract member UnityEngine.UI.BaseMeshEffect.ModifyMesh(UnityEngine.UI.VertexHelper)'”
I copied the code from post #15 and get this error. It dosen’t seem to register the VertexHelper inside of the function. Or something. Ideas?
public override void ModifyMesh( VertexHelper vh )
{
if( !IsActive() )
return;
List<UIVertex> list = new List<UIVertex>();
vh.GetUIVertexStream( list );
ModifyVertices( list );
vh.Clear();
vh.AddUIVertexTriangleStream( list );
}
Should work, not sure if it’s the best way to implement, but currently works for me in 5.3