Using GetComponentInChildren

I have an object that has a child object which contains a renderer. I want the parent to be able to access the renderer in a C# script. I tried

Renderer rend = GetComponentInChildren();

and got “The non-generic method GetComponentInChildren cannot be used with type arguments.” Then I tried

Renderer rend = GetComponentInChildren(Renderer);

and got “Expression denotes a type, where a variable, value or method group was expected.” What’s the correct way to do this?

I use this sweet little function all the time:

Call it like this:

GetChild("Ana-PF-Geometry").GetComponent(SkinnedMeshRenderer).enabled=true;
function GetChild( name : String) : GameObject {

   transforms = GetComponentsInChildren( typeof( Transform ), true );
	var i = 0;
	for (i=0;i<transforms.length;i++)
   {
      if( transforms[i].gameObject.name == name )
      {
         return transforms[i].gameObject;
      } 
   }
   return null;
}