Мои Уведомления
Привет, !
Мой Аккаунт Мои Финансы Мои Подписки Мои Настройки Выход
Руководство API скрипты

Объявление

public Component GetComponentInChildren(Type type);

public Component GetComponentInChildren(Type type, bool includeInactive);

Параметры

type Тип компонента для получения.

Возвращает

Component Компонент соответствующего типа, если он найден

Описание

Возвращает компонент Type type в GameObject или любом из его дочерних элементов, используя поиск в глубину.

Компонент возвращается, только если он найден в активном игровом объекте.

using UnityEngine; public class GetComponentInChildrenExample : MonoBehaviour { // Disable the spring on the first HingeJoint component found on any child object void Start() { HingeJoint hinge = gameObject.GetComponentInChildren(typeof(HingeJoint)) as HingeJoint; if (hinge != null) hinge.useSpring = false; else { // Try again, looking for inactive GameObjects HingeJoint hingeInactive = gameObject.GetComponentInChildren(typeof(HingeJoint), true) as HingeJoint; if (hingeInactive != null) hingeInactive.useSpring = false; } } }

Объявление

public T GetComponentInChildren(bool includeInactive = false);

Возвращает

T Компонент соответствующего типа, если он найден.

Описание

Общая версия этого метода.

using UnityEngine; public class GetComponentInChildrenExample : MonoBehaviour { // Disable the spring on the first HingeJoint component found on any child object void Start() { HingeJoint hinge = gameObject.GetComponentInChildren<HingeJoint>(); if (hinge != null) hinge.useSpring = false; else { // Try again, looking for inactive GameObjects HingeJoint hingeInactive = gameObject.GetComponentInChildren<HingeJoint>(true) as HingeJoint; if (hingeInactive != null) hingeInactive.useSpring = false; } } }
Вы можете отблагодарить автора, за перевод документации на русский язык. ₽ Спасибо
API скрипты 2021.3