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.GetComponentsInChildren 获取子物体组件列表
function GetComponentsInChildren (type : Type, includeInactive : bool = false) : Component[]
Description描述
Returns all components of Type type in the GameObject or any of its children.
Only active components are returned.
得到游戏物体或者其所有子物体上的所有类型为type的组件。
只返回活动的组件。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public HingeJoint[] hingeJoints;
public void Awake() {
hingeJoints = gameObject.GetComponentsInChildren<HingeJoint>();
foreach (HingeJoint joint in hingeJoints) {
joint.useSpring = false;
}
}
}
// 使这个游戏物体及其子物体上的所有HingeJoints上的spring不可用.
var hingeJoints : HingeJoint[];
hingeJoints = gameObject.GetComponentsInChildren(HingeJoint);
for (var joint : HingeJoint in hingeJoints) {
joint.useSpring = false;
}
最后修改:2011年1月16日 Sunday 17:51