var wantedLayer = 1;
function Start ()
{
var children = GetComponentsInChildren (Transform);
for (var child in children)
t.gameObject.layer = wantedLayer;
}
Here’s a function I wrote based on your code (fixed your typo) that does the trick:
function AssignLayerDeep (theInstance, theLayer) {
var children = theInstance.GetComponentsInChildren (Transform);
for (var t : Transform in children) t.gameObject.layer = theLayer;
}