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;
script = gameObject.GetComponentInChildren(ScriptName);
script.DoSomething ();
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
public ScriptName script;
void Awake() {
script = gameObject.GetComponentInChildren<ScriptName>();
script.DoSomething();
}
}
import UnityEngine
import System.Collections
class example(
MonoBehaviour):
public script as ScriptName
def
Awake():
script = gameObject.GetComponentInChildren[of ScriptName]()
script.DoSomething()