how to fade out an animation (using alpha)

I have an animation that I want to fade out. Essentially, I have a reference to a Transform object (called “toHide”), and something like this works:

while (toHide.renderer.material.color.a > 0.01f)
{
	toHide.renderer.material.color = Color.Lerp (toHide.renderer.material.color, new Color(1, 1, 1, 0), Time.deltaTime);
	yield return null;
}

But what I want to really do is fade out the animation starting at a given frame. So, I know that the animation has, say, 100 frames. But I don’t want to start fading it out until frame 80 (for example).

Any ideas?

I’m not sure exactly what you want to do, but it sounds like you want something to happen when some animation has reached a specific frame?

If toHide has an attached Animation component that’s playing the animation in question, I can think of two ways to set up a hook:

If you’re trying to switch from one animation to another, Animation.CrossFade() or Blend() might be handy.

Sorry if that’s not what you’re looking for. Seems close but not quite on the mark?