I am developing and android game where i fade in enemy when the spawn, the problem is that the enemy prefabs have 2 skinned mesh renderer material(ZombearMaterial, EyeMaterial). I use the down given code to fade in the enemy but the problem I face is that the script is only able to fade in the first element in the hierarchy. So how can I access and change all the skinned mesh renderer material in a Gameobject.
Fade In
public Material enemyAlpha;
public float fadetime;
// Use this for initialization
void Start () {
enemyAlpha = GetComponent<SkinnedMeshRenderer> ().material;
}
// Update is called once per frame
void Update () {
fadetime = (Time.time)/2;
fadeIn (fadetime);
}
void fadeIn(float time)
{
enemyAlpha.color = new Color (1, 1, 1, (time));
}
Gameobject inspector