Component
- animation
- audio
- BroadcastMessage
- camera
- collider
- CompareTag
- constantForce
- gameObject
- GetComponent.<T>
- GetComponentInChildren.<T>
- GetComponentInChildren
- GetComponents.<T>
- GetComponentsInChildren.<T>
- GetComponentsInChildren
- GetComponents
- GetComponent
- guiTexture
- guiText
- hingeJoint
- light
- networkView
- particleEmitter
- renderer
- rigidbody
- SendMessageUpwards
- SendMessage
- tag
- transform
Component.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 = GetComponents<HingeJoint>();
foreach (HingeJoint joint in hingeJoints) {
joint.useSpring = false;
}
}
}
// Disable the spring on all HingeJoints in this game object
//在这个游戏物体禁用全部铰链关节上的弹簧
var hingeJoints : HingeJoint[];
hingeJoints = GetComponents (HingeJoint);
for (var joint : HingeJoint in hingeJoints) {
joint.useSpring = false;
}
最后修改:2011年1月16日 Sunday 17:40