FadeIn color material not working?

Hi,

i don’t understand how to fade in the color of a simple cube, like with the code from this page (Fade In _TintColor Over Time - Questions & Answers - Unity Discussions)

var color : Color ;
var secondsToFade : float = 20 ;
var red : float = 0.5 ;
var green : float = 0.5 ;
var blue : float = 0.5 ;
var alpha : float = 0 ;
 
function Update(){
   color = Color(red, green, blue, alpha) ;
   alpha = Mathf.Lerp(0, 1, Time.time / secondsToFade) ;
   renderer.material.SetColor("_TintColor" , color) ;
}

Edit: i have also tried this :

function Start () {
	// Set specular shader
    renderer.material.shader = Shader.Find ("Specular");
    // Set red specular highlights
    renderer.material.SetColor ("_SpecColor", Color.red);
}
 
function Update(){
   color = Color(red, green, blue, alpha) ;
   alpha = Mathf.Lerp(0, 1, Time.time / secondsToFade) ;
   renderer.material.SetColor("_TintColor" , Color.black) ;//color
}

It does not work with my example. In the properties, the Color parameter seems to be loading something, but the material color never changes (the script is linked to the cube). Would anyone know why?

Thanks

That shadder isn’t transparent, so fading the alpha won’t do anything. Change the shader, or lerp between a startColor and endColor. And make sure there is a _TintColor parameter in your shader.