Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Component.GetComponents

マニュアルに切り替える
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();

説明

ジェネリック版。詳細については Generic Functions を参照してください