****Im trying to apply a different color and texture for a period of time on the mesh of characters in a fightgame.(like a subzero move)
i would like to know how to reload the original texture that I have changed after few seconds.
Thanks for any advice.
using UnityEngine;
using System.Collections;
public class meshcolor : MonoBehaviour {
public Color colorStart = Color.red;
public Color colorEnd = Color.green;
public float duration = 1.0F;
public Texture texture; //*the new texture*
void Update() {
foreach(GameObject fooObj in GameObject.FindGameObjectsWithTag("character"))
{
float lerp = Mathf.PingPong(Time.time, duration) / duration;
fooObj.renderer.material.color = Color.Lerp(colorStart, colorEnd, lerp);
fooObj.renderer.material.mainTexture = texture;
StartCoroutine(resetrender());
}
}
IEnumerator resetrender() {
yield return new WaitForSeconds(3);
foreach(GameObject fooObj in GameObject.FindGameObjectsWithTag("character"))
{
fooObj.renderer.material.color = Color.white; *// here I reset the material.color and its working in this way*
}
}
}