How to access child object colours.

Hi, How do I access colours of children of an empty object. I have an object made of many children and I would like to turn all the children's colours to transparent to make it vanish and appear.

I tried GetComponentsInChildren, but can't get the syntax right or something.

Sorry I can't provide a sample script, but I just can't get anything to work.

Thanks for any help.

Thanks Guys for pointing me in the right direction, I've got it now. It goes something like this...

// first set z key as key to switch colours;

function Update() {

if (Input.GetKeyDown(KeyCode.Z)) {



// no idea what the () syntax means but it works;

function DoRender(){

var children : Renderer[];

children = GetComponentsInChildren.<Renderer>();

Debug.Log (children);

for (var i : Renderer in children) {

i.material.color =;



var children : Renderer = GetComponentsInChildren(Renderer);

for (var i : Renderer in children) {

    i.material.color =


This should give you the idea.

var renderers = GetComponentsInChildren(Renderer);
for (render in renderers) render.material.color.a = 0.0;