How to quickly change the texture on a material?

For my 2D game, I am making my player sprite. In my script, I try to change the texture on the material every 1/10 of a second, but it keeps glitching. I need it to loop. Here is the code:

var walk1 : Texture2D;
var walk2 : Texture2D;
var walk3 : Texture2D;

function Update () {
	if(Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) {
		renderer.material.mainTexture = walk1;
		wait(0.1);
		renderer.material.mainTexture = walk2;
		wait(0.1);
		renderer.material.mainTexture = walk3;
		wait(0.1);
		renderer.material.mainTexture = walk2;
		wait(0.1);
	}
}

function wait(amount : float) {
	yield WaitForSeconds(amount);
}

You need to do a bit of research on coroutines. The call to wait() returns immediately. Any lines of code after the yield (which you don’t have any here) would be execute after the specified amount of time. But still the the initial call to wait() returns the first time a yield is hit. So this code will not wait.

Here is a post doing something similar with an array of textures. The textures are initialized in the Inspector:

http://answers.unity3d.com/questions/392517/introduction-movie.html

In addition there are several scripts for animation in the Unity Wiki. Here is one:

http://wiki.unity3d.com/index.php?title=Animating_Tiled_texture