docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ComponentUtils<T>

    Special utility class for getting components in the editor without allocations.

    Inheritance
    object
    ComponentUtils<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.XR.CoreUtils
    Assembly: Unity.XR.CoreUtils.dll
    Syntax
    public static class ComponentUtils<T>
    Type Parameters
    Name Description
    T

    The type of component for which to be searched.

    Methods

    GetComponent(GameObject)

    Gets a single component of type T using the non-allocating GetComponents API.

    Declaration
    public static T GetComponent(GameObject gameObject)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject from which to get the component.

    Returns
    Type Description
    T

    The component, if one exists.

    GetComponentInChildren(GameObject)

    Gets a single component of type T using the non-allocating GetComponentsInChildren API.

    Declaration
    public static T GetComponentInChildren(GameObject gameObject)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject from which to get the component.

    Returns
    Type Description
    T

    The component, if one exists.

    In This Article
    Back to top
    Copyright © 2025 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)