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

スクリプト言語

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

Component.GetComponentsInChildren

マニュアルに切り替える
public Component[] GetComponentsInChildren(Type t, bool includeInactive = false);
public Component[] GetComponentsInChildren(Type t, bool includeInactive = false);

パラメーター

t 取得するコンポーネントの型
includeInactive 非アクティブのコンポーネントも含めるかどうか

説明

GameObject や深さ優先探索を活用して、親子関係にある子オブジェクトから type のタイプのコンポーネントを「すべて」取得します。

using UnityEngine;
using System.Collections;

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

public T[] GetComponentsInChildren(bool includeInactive);

パラメーター

includeInactive 非アクティブのゲームオブジェクトも含めるかどうか

戻り値

T[] 指定した型に一致したすべてのコンポーネントのリスト

説明

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


public T[] GetComponentsInChildren();

戻り値

T[] 指定した型に一致したすべてのコンポーネントのリスト

説明

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