Does anybody know how to change the fill color of a slider in Unity 4.6 at runtime?
Any help gratefully received.
Does anybody know how to change the fill color of a slider in Unity 4.6 at runtime?
Any help gratefully received.
This worked for me, at the top be sure to add “using System.Linq;”:
var fill = (slider as UnityEngine.UI.Slider).GetComponentsInChildren<UnityEngine.UI.Image>()
.FirstOrDefault(t => t.name == “Fill”);
if (fill != null)
{
fill.color = Color.Lerp(Color.red, Color.green, 0.5);
}
Thanks a lot, that worked.
How would we do this in java?
change the using System.Linq; to import using System.Linq;
then copy the code and past it where do you want
Works perfect, the only thing i changed was to get a hold on the image on start/wake to a property to avoid calling this function on update, i also pass the colors as a parameter. thanks.