Animate a GUITexture

I have a GUITexture and I want to change its texture to iterate through an array of textures over a given period of time. I found the Texture Swap Animator on the Unify wiki which iterates through the images a set number of frames a second using the following:

[Edits made re. Eric's answer, but still problems, see comments]

    var myTextures : Texture2D[];  
    var framesPerSecond : float = 10.0;
    var dripPlaying : boolean = false;

    function Start(){

     guiTexture.enabled = false;

    }

     function Update () {

    Debug.Log(guiTexture.texture.name);

        if(dripPlaying == true){

            var i : int = Time.time * framesPerSecond;
            i = i % myTextures.length;

            guiTexture.texture = myTextures*;*
 *guiTexture.enabled = true;*
 *if(i == myTextures.length-1){*
 *dripPlaying = false;*
 *guiTexture.enabled = false;*
 *}*
 *}*
 *}*
*```*
*<hr>*
*<p>To clarify: I have a simple sphere with an animation that moves it along the y-axis (dropping from a shower head). I created this animation in the animation editor. On the frame in the animation where it would be hitting the floor, there is an animation event which calls the following function. The dripPlaying boolean that is changed by this function should start the animated GUITexture from the above script playing.</p>*
*```*
*var audioVolume = 1.0;*
*var collisionSoundEffect : AudioClip;*
*function playSound(){*
 *//Debug.Log("Animation event called");*
 *audio.volume = audioVolume;*
 *audio.clip = collisionSoundEffect;*
 *audio.Play();*
 *otherscript = GameObject.Find("dripGUI").GetComponent("guiAnim");*
 *otherscript.dripPlaying = true;*
 *//GameObject.Find("dripGUI").GetComponent(GUITexture).enabled = true;*
*}*
*@script RequireComponent(AudioSource)*
*```*
*<p>But i'm still not seeing every frame. I tried to confirm using Debug.Log() but it doesn't seem to change, despite being in the Update() function. My other question can be found <a href="http://answers.unity3d.com/questions/6962/play-sound-on-animation-event" rel="nofollow">here</a>.</p>*
*<p>If someone could shed some light on this, i'd appreciate it.</p>*
*<p>Thanks.</p>*

OK, I see now that you just want the frame animation to play once, yes? In this case it would be simpler to use a coroutine function for this, since Update is intended for things that run all the time:

var framesPerSecond = 10.0;
var myTextures : Texture2D[];

function PlayAnim () {
    var waitTime = 1.0/framesPerSecond;
    for (i = 0; i < myTextures.Length; i++) {
        guiTexture.texture = myTextures*;*
 *yield WaitForSeconds(waitTime);*
 *}*
 *guiTexture.enabled = false;*
*}*
*```*
*<p>Then change</p>*
*```*
*otherscript.dripPlaying = true;*
*```*
*<p>to</p>*
*```*
*otherscript.PlayAnim();*
*```*

With your `for` loop, you're looping through all the textures in one frame, so you will never see any but the last. You can't use `yield` in Update, because it always runs every frame. Since you already have a variable to start or stop the animation, you could use that to stop the animation when the frame index gets to the end:

if(dripPlaying == true){
    var i : int = Time.time * framesPerSecond;
    i = i % myTextures.length;
    guiTexture.texture = myTextures*;*
 *if (i == myTextures.length-1) dripPlaying = false;*
*}*
*```*

You could also try a script like the following, which makes use of Mono’s System.Drawing library: http://wiki.unity3d.com/index.php/AnimatedGifDrawer