Search Results for

    Show / Hide Table of Contents

    Class MonoBehaviourExtensions

    UnityEngine.MonoBehaviour Based Extension Methods

    Inheritance
    System.Object
    MonoBehaviourExtensions
    Namespace: GDX
    Syntax
    [VisualScriptingCompatible((short)2)]
    public static class MonoBehaviourExtensions

    Methods

    | Improve this Doc View Source

    GetFirstComponentInChildrenComplex<T>(MonoBehaviour, Boolean, Boolean, Int32)

    A slightly more complex version of UnityEngine.Component.GetComponentInChildren<T>(System.Boolean) which allows for different hinted search options.

    Declaration
    public static T GetFirstComponentInChildrenComplex<T>(this MonoBehaviour targetMonoBehaviour, bool includeInactive = false, bool lookInChildrenFirst = false, int maxLevelsOfRecursion = -1)
        where T : Component
    Parameters
    Type Name Description
    UnityEngine.MonoBehaviour targetMonoBehaviour

    The target UnityEngine.MonoBehaviour to use as the base for the search.

    System.Boolean includeInactive

    Include inactive child UnityEngine.GameObjects when looking for the UnityEngine.Component.

    System.Boolean lookInChildrenFirst

    Should children UnityEngine.GameObject be searched before the targetMonoBehaviour's UnityEngine.GameObject.

    System.Int32 maxLevelsOfRecursion

    The maximum levels of recursion when looking for a UnityEngine.Component, -1 for infinite recursion.

    Returns
    Type Description
    T

    The first found UnityEngine.Component.

    Type Parameters
    Name Description
    T

    The target UnityEngine.Component type that is being looked for.

    Remarks

    If the maxLevelsOfRecursion is set to 1; this will search the targetMonoBehaviour and its immediate children only.

    The internal UnityEngine.Component.GetComponentInChildren<T>(System.Boolean) has optimizations internally in engine code which make it faster in different scenarios.

    Exceptions
    Type Condition
    UnsupportedRuntimeException

    Not supported on DOTS Runtime.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Built on 2024-01-01 against 1f69a68.
    Generated by Dox+DocFX.