Component.GetComponentsInParent

Switch to Manual
public Component[] GetComponentsInParent (Type t, bool includeInactive= false);

Parameters

t@param type Тип возвращаемого компонента.
includeInactive@param includeInactive Следует ли включать неактивные компоненты в список найденных?

Description

Возвращает все компоненты типа type в GameObject или любому из его родителей.

using UnityEngine;

public class GetComponentsInParentExample : MonoBehaviour { public Component[] hingeJoints;

void Start() { // Disable the spring on all HingeJoints // in this game object and all its parent game objects hingeJoints = (HingeJoint[])gameObject.GetComponentsInParent(typeof(HingeJoint));

foreach (HingeJoint joint in hingeJoints) { joint.useSpring = false; } } }

public T[] GetComponentsInParent (bool includeInactive);
public T[] GetComponentsInParent ();

Parameters

includeInactive@param includeInactive Следует ли включать неактивные компоненты в список найденных?

Description

Дженерик функции. Для получения дополнительной информации смотрите страницу, посвященную Дженерик функциям.