Version: 5.5
public Component[] GetComponentsInChildren (Type t, bool includeInactive= false);

パラメーター

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

説明

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

using UnityEngine;

public class GetComponentsInChildrenExample : 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 を参照してください。