Change UI Image's source from script using collected items number

Hello, I’m making a game using Unity 5.
I have an image on UI canvas that I want to display the amount of collected items, I have it with a counter, but what I want is to replace the numbers by the image.

This is what I have:

43242-screen-shot-2015-03-24-at-141005.png

This is the code (C#) that updates the counter text:

void CollectCandy (Collider2D candyCollider)
{
	candiesCollected++;
	Destroy (candyCollider.gameObject);
	AudioSource.PlayClipAtPoint (candyCollectSound, transform.position);
	candiesLabel.text = candiesCollected.ToString ();
}

What I need to know is what would be the best way to use the image as a collected items meter, I have the sprites to use whit it

43244-screen-shot-2015-03-24-at-141629.png

I was thinking on use an animation and going frame by frame but I don’t know how to do that, I also was thinking on trying to replace the UI Image’s source by script, but I can’t figure out how to do that either.

Can you help me how to make this part working?
Thanks.

Hello,

You can keep your UI Image in a variable and then just load the sprite and assign it to the image when needed

public Image image;

void changeImage() {
    //Assuming med2 is in resources, otherwise you have to write your path also in the load method.
    Sprite sprite = Resources.Load<Sprite>("med2");
    image.sprite = sprite;
}