I was wondering if there was a way to fade or animate a texture like the particle emmiters do, but on a material.
thanks
I was wondering if there was a way to fade or animate a texture like the particle emmiters do, but on a material.
thanks
Make sure the shader you're using has an alpha channel, then it's easy as lerping the alpha value to 0. As far as animating the texture, you can modify the scale and offset values, or the UVs directly.
An example class (C#):
public static IEnumerator LerpAlpha(float newAlphaValue, float time, GameObject gameObjectToFade)
{
newAlphaValue = Mathf.Clamp01(newAlphaValue);
Color col = new Color();
col.a = 1.0f;
Component[] renderer = gameObjectToFade.GetComponentsInChildren(typeof(MeshRenderer));
while(col.a >= newAlphaValue)
{
foreach(Renderer r in renderer)
foreach(Material mat in r.materials)
{
col = mat.color;
col.a -= ( (1.0f - newAlphaValue) / time) * Time.deltaTime;
mat.color = col;
}
yield return 0;
}
yield return 0;
}