言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

GameObject.GetComponentInChildren

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public function GetComponentInChildren(type: Type): Component;
public Component GetComponentInChildren(Type type);
public def GetComponentInChildren(type as Type) as Component

Parameters

type 取得するコンポーネントの型

Description

深さ優先探索でゲームオブジェクトまたはゲームオブジェクトの子たちの type からコンポーネントを取得します。

アクティブのコンポーネントのみ返します。

// Disable the spring of the first HingeJoint component
// found on any child object.

var hinge : HingeJoint;
hinge = gameObject.GetComponentInChildren(HingeJoint);
hinge.useSpring = false;
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public HingeJoint hinge;
    void Example() {
        hinge = gameObject.GetComponentInChildren<HingeJoint>();
        hinge.useSpring = false;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public hinge as HingeJoint

	def Example() as void:
		hinge = gameObject.GetComponentInChildren[of HingeJoint]()
		hinge.useSpring = false

public function GetComponentInChildren(): T;
public T GetComponentInChildren();
public def GetComponentInChildren() as T

Description

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