Component.GetComponents Manual     Reference     Scripting  
Scripting > Runtime Classes > Component
Component.GetComponents

function GetComponents (type : Type) : Component[]

Description

Returns all components of Type type in the GameObject.

// Disable the spring on all HingeJoints
// in this game object
var hingeJoints = GetComponents (HingeJoint);
for (var joint : HingeJoint in hingeJoints) {
joint.useSpring = false;
}

For C# users there is a generic version available.

// Disable the spring on all HingeJoints
// in this game object
HingeJoint[] hingeJoints = GetComponents<HingeJoint>();
for (HingeJoint joint in hingeJoints) {
joint.useSpring = false;
}