Material transition through animation

I have this script that ping pongs back and forth between two materials (doesn’t transition textures but that’s fine with me for what I’m doing). How would I change it so that instead of ping ponging I can cause the transition to happen through using animation events? So, I could have an animation that on frame 60 I trigger a transition to material 2 and on frame 120 transition back to material 3.

using UnityEngine;
using System.Collections;

public class swap_mats : MonoBehaviour {
	// Blends between two materials
	public Material material1;
	public Material material2;
	public float duration = 2.0F;
	public Renderer rend;
	void Start() {
		// At start, use the first material
		rend = GetComponent<Renderer>();
		rend.material = material1;
	}
	void Update() {
		// Ping-pong between the materials over the duration
		float lerp = Mathf.PingPong(Time.time, duration) / duration;
		rend.material.Lerp(material1, material2, lerp);
	}
}

As far as I understand the animation events, you need two public methods. One to transition from material 1 to 2 and one form 2 to 1. Then you select your animation in the editor and in the timeline you can create an animation event (through the right click context menu I guess) where you need to pull in the game object that has this script attached and select the corresponding function.

I read the documentation on coroutines then came up with this (down below) for the code to use. It doesn’t work: I now don’t even get the immediate transitions I was seeing before. Now it just does a one frame flash at the end of the animation (neither of my animation events are at the end of the animation).

Also, I’m pretty sure what I have in update isn’t right. I don’t know how to do this because I think it’s more complicated than the example used in the documentation. I only say this because, for mine, I only want to restart the coroutine “SwitchToMat1”, for example, if that coroutine is not finished yet. Or do I misunderstand how coroutines work?

using UnityEngine;
using System.Collections;

public class swap_mats : MonoBehaviour {
	public Material material1;
	public Material material2;
	public Renderer rend;
	void Start() {
		rend = GetComponent<Renderer>();
		rend.material = material1;
	}
	void Update() {
			StartCoroutine("SwitchToMat1");
			StartCoroutine("SwitchToMat2");
	}
	public IEnumerator SwitchToMat1() {
		GetComponent<Renderer>().material.Lerp(material2, material1, Time.deltaTime);
		yield return null;
	}
	public IEnumerator SwitchToMat2() {
		GetComponent<Renderer>().material.Lerp(material1, material2, Time.deltaTime);
		yield return null;
	}
}

Side note: I decided to remove the “speed” multiplier since without it you said I should still be seeing a one second transition, which should work just fine for what I’m doing.