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.GetComponents 获取组件列表
function GetComponents (type : Type) : Component[]
Description描述
Returns all components of Type type in the GameObject.
返回这个游戏物体上的所有类型为type的组件。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public HingeJoint[] hingeJoints;
public void Awake() {
hingeJoints = gameObject.GetComponents<HingeJoint>();
foreach (HingeJoint joint in hingeJoints) {
joint.useSpring = false;
}
}
}
// Disable the spring on all HingeJoints
// in this game object
// 使这个游戏物体上的所有HingeJoints上的spring不可用.
var hingeJoints : HingeJoint[];
hingeJoints = gameObject.GetComponents (HingeJoint);
for (var joint : HingeJoint in hingeJoints) {
joint.useSpring = false;
}
最后修改:2010年12月13日 Monday 17:50