outer glow

How to apply fade in and fade out outer glow in character. Let i have male character if he collide with a box his out line of his body should start fade in and fade out in green color as indication he have reached that point 3 to 4 times. I am new to unity i have applied toon shader basic outline. It is just showing the outer glow i want to fade in and fade out that glow.How to get that effect

You can make the outline color vary in intensity, like below. This will only work with the Toon Ouline shaders.

// requires Toon/Basic Outline or Toon/Lighted Outline shader!
var hilite: boolean = false;  // turns glow on/off
var color: Color = Color.green;  // glow color
var width: float = 1.0;  // outline width
var duration: float = 2.0;  // duration of each cycle in seconds

function Update(){
	if (hilite){
		renderer.material.SetFloat("_Outline", width * 0.005);
		var c = color * Sinusoid(duration, 0.5, 1);
		renderer.material.SetColor("_OutlineColor", c);
	} else {
		renderer.material.SetFloat("_Outline", 0);

function Sinusoid(period: float, min: float, max: float): float {
    var bias = (min + max) / 2;
    var depth = (max - min) / 2;
    return depth*Mathf.Sin(2*Mathf.PI*Time.time/period)+bias;


1- Attach this script to the object to be hilighted;

2- The outline thickness is constant, no matter how far the object is from the camera - at longer distances it will appear too thick, and too thin when closer.