public Component[] GetComponents (Type type);

参数

type要检索的组件的类型。

描述

返回 GameObject 中类型为 type 的所有组件。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public HingeJoint[] hingeJoints; void Example() { hingeJoints = GetComponents<HingeJoint>(); foreach (HingeJoint joint in hingeJoints) { joint.useSpring = false; } } }

public T[] GetComponents ();

描述

通用版本。有关更多详细信息,请参阅通用函数页面。