- Home /
Fade out a line renderer?
Hi! I am trying to make my line renderer fade out, but I have encountered some problems...
When using the Unity built in Particle shaders, you can't access the color of the renderer. So after some searching around I found out that you had to access the _Tint property(?) (can't remember exactly what its called). I have tried to set this up, but haven't been able to make it work...
Does anyone know how you make a line renderer fade out?
Answer by robertbu · Jul 14, 2013 at 10:53 PM
You can access the tint color using the Material.SetColor() function. The property is called "_TintColor". The name you use in GetColor()/SetColor() is not the name that appears in the Inspector. For these built-in shaders you can find the source here:
http://download-cdn.unity3d.com/unity/download/archive
You can look at the source to see how the property is named. Note that this shader makes the object fully visible with a alpha of 0.5, so you will need to fade from 0.5 to 0.0.
Thanks alot!
After 30 $$anonymous$$utes I found out that I was using the Particles/Addative(Soft) shader which doesn't have any color at all... So I had to access the LineRenderer colors ins$$anonymous$$d. And now it works like a charm :)
void Start()
{
line = gameObject.GetComponent<LineRenderer>();
alpha = 0.5f;
line.material = new $$anonymous$$aterial(Shader.Find("Particles/Additive (Soft)"));
}
void Update()
{
alpha -= Time.deltaTime * speed;
Color start = Color.white;
start.a = alpha;
Color end = Color.black;
end.a = alpha;
line.SetColors (start, end);
}