GameObject.GetComponentInChildren Manual     Reference     Scripting  
Scripting > Runtime Classes > GameObject
GameObject.GetComponentInChildren

function GetComponentInChildren (type : Type) : Component

Description

Returns the component of Type type in the GameObject or any of its children using depth first search.

Only active components are returned

var script : ScriptName = gameObject.GetComponentInChildren(ScriptName);
script.DoSomething ();

For C# users there is a generic version available.

ScriptName script = gameObject.GetComponentInChildren<ScriptName>();
script.DoSomething ();