Flickering Animation

I’m trying to create a game, but I want an object (e.g. a cube) so it looks like its flickering on and off. Then, when you get close enough, a collider makes it disappear. Is there any scripts that make this possible. Thanks.

Could you do something like this?

bool flickerOn = true;
void Update()
{
  flickerOn = !flickerOn;    
  gameObject.renderer.enabled = flickerOn;
}

This would flicker pretty fast so you may put a frame count around it.