docs.unity.cn
    Show / Hide Table of Contents

    Method GetComponentInChildren

    GetComponentInChildren<T>()

    Returns the component of Type T in the GameObject or any of its children using depth first search

    Declaration
    public T GetComponentInChildren<T>()
        where T : Component
    Returns
    Type Description
    T

    The component if a component matching the type is found, null otherwise

    Type Parameters
    Name Description
    T

    The type of component to retrieve

    Remarks

    This will take a dependency on the component

    GetComponentInChildren<T>(Component)

    Returns the component of Type T in the GameObject or any of its children using depth first search

    Declaration
    public T GetComponentInChildren<T>(Component component)
        where T : Component
    Parameters
    Type Name Description
    Component component

    The Object to get the component from

    Returns
    Type Description
    T

    The component if a component matching the type is found, null otherwise

    Type Parameters
    Name Description
    T

    The type of component to retrieve

    Remarks

    This will take a dependency on the component

    GetComponentInChildren<T>(GameObject)

    Returns the component of Type T in the GameObject or any of its children using depth first search

    Declaration
    public T GetComponentInChildren<T>(GameObject gameObject)
        where T : Component
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject to get the component from

    Returns
    Type Description
    T

    The component if a component matching the type is found, null otherwise

    Type Parameters
    Name Description
    T

    The type of component to retrieve

    Remarks

    This will take a dependency on the component

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023