docs.unity3d.com
Search Results for

    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

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)