How change slider(prefab) fill color in a script?

Hi guys,

I have a healthbar attached to my prefab enemy tanks in a “desert strike” clone I’m building.

I have created a healthbar slider in a worldspace canvas and attached this canvas and script to my enemy prefab - It all works great so far.

Problem: I want to start the fill color at green and reduce it to red as the health value decreases. I know how to lerp the color, but I just cant work out how to actually change the color of the object! I have scoured the internet for an answer to this but its not even in the unity scripting manual!

I understand the fil color is at: Slider>Fill Area>Fill>Image>color. But how do I change this in c#???

Cheers

Ok, this has now been addressed in the Unity Tanks! tutorial. Details added for others’ benefit.

 private void SetHealthUI ()
    {
        // Set the slider's value appropriately.
        m_Slider.value = m_CurrentHealth;

        // Interpolate the color of the bar between the chosen colours based on the current percentage of the starting health.
        m_FillImage.color = Color.Lerp (m_ZeroHealthColor, m_FullHealthColor, m_CurrentHealth / m_StartingHealth);
    }