Fade In _TintColor Over Time

Hello,

I have a game object that has a material attached to it. The material is a Particles/Alpha Bleneded, and by default, the Tint Color Alpha is set to 0.

What I want to be able to do, is to increase the Tint Color Alpha over time. Any ideas?

I’ve tried doing something like this:

var increase = 0;
var color : Color = Color(0.5, 0.5, 0.5, increase);

renderer.material.SetColor ("_TintColor", color);

for(var i = 0; i < 10; i++){
    increase = increase + 0.05;
    yield WaitForSeconds(0.01);
}

But nothing happens.
Please help!

Thanks

I suggest using iTween which takes care of such thing for you:

http://itween.pixelplacement.com/index.php

It’s pretty powerful and free to use…
Read the documentation on how to use it. I think you might want to check on the ColorTo method.

hope this is useful

cheers!

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) ;
}