Animated Texture

If i put the function below, in Update() it will show one image after another,… but then it will be stuck on the last image, and not repeat beginning from the first image (grid1),… What is going on ? It’s in Update() so it should continue to loop right ?

function AnimatePlane()
{
AllItems[20].renderer.material.mainTexture = Resources.Load(“grid1”);
yield WaitForSeconds(0.4);
AllItems[20].renderer.material.mainTexture = Resources.Load(“grid2”);
yield WaitForSeconds(0.4);
AllItems[20].renderer.material.mainTexture = Resources.Load(“grid3”);
yield WaitForSeconds(0.4);
AllItems[20].renderer.material.mainTexture = Resources.Load(“grid4”);
yield WaitForSeconds(0.4);
AllItems[20].renderer.material.mainTexture = Resources.Load(“grid5”);
yield WaitForSeconds(0.4);
}

Or this… Gives EXACTLY the same result …

var textures : Object[ ];
var texture : Texture2D;
var y1 : int;

function AnimatePlane()
{
textures = Resources.LoadAll(“Grid”, Texture2D);
for (y1=0;y1<5;y1++)
{
texture = textures[y1];
AllItems[20].renderer.material.mainTexture = texture;
yield WaitForSeconds(0.4);
}
}

Never mind, already found it… Unity - Scripting API: Material.mainTexture