GameObject
- active
- AddComponent.<T>
- AddComponent
- animation
- audio
- BroadcastMessage
- camera
- collider
- CompareTag
- constantForce
- CreatePrimitive
- FindGameObjectsWithTag
- FindWithTag
- Find
- GameObject
- GetComponent.<T>
- GetComponentInChildren.<T>
- GetComponentInChildren
- GetComponents.<T>
- GetComponentsInChildren.<T>
- GetComponentsInChildren
- GetComponents
- GetComponent
- guiTexture
- guiText
- hingeJoint
- isStatic
- layer
- light
- networkView
- particleEmitter
- renderer
- rigidbody
- SampleAnimation
- SendMessageUpwards
- SendMessage
- SetActiveRecursively
- tag
- transform
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
返回这个游戏物体或者它的所有子物体上(深度优先)的类型为type的组件。
只返回活动的组件。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public ScriptName script;
public void Awake() {
script = gameObject.GetComponentInChildren<ScriptName>();
script.DoSomething();
}
}
var script : ScriptName;
script = gameObject.GetComponentInChildren(ScriptName);
script.DoSomething ();
最后修改:2010年12月13日 Monday 17:52