Fade out children of gameobject

Hi all,

I was wondering how to do the following: I have a 3D object (dae format) which I imported into Unity. Unity imported this as a container game object with all the different parts as children of this game object.

Now i want to fade out the game object, but when I apply a material to the parent and change the alpha component of the Color object, nothing happens.
I’ve tried to do the same with a simple cube, and then it does work.

I guess this is because the parent gameobject, is just an container for everything that’s inside. So is there an easy way to get all the children and fade these out?

Or is there another way of fading out the parent by code?

Cheers,
Frederik

To change the color, you’ll have to set the color on all the individual object. It is even possible that individual objects will have a materials array, and you’ll have to set the color on all the materials on each object. You can get all the renderers using Transform.GetComponentsInChildren().

On a script on the parent object, you can do:

var renderers : GetComponentsInChildren (Renderer);
for (var rend : Renderer in renderers) {
    rend.material.color = Color.red;
}

More information on changing the color of objects:

http://answers.unity3d.com/questions/795049/oafathow-do-i-changer-the-color-of-a-game-object.html