docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method GetComponentObject

    GetComponentObject<T>(Entity)

    Gets the managed UnityEngine.Component object from an entity.

    Declaration
    [ExcludeFromBurstCompatTesting("Returns managed object")]
    public T GetComponentObject<T>(Entity entity)
    Parameters
    Type Name Description
    Entity entity

    The entity.

    Returns
    Type Description
    T

    The managed object, cast to type T.

    Type Parameters
    Name Description
    T

    The type of the managed object.

    Remarks

    Accessing data in a managed object forfeits many opportunities for increased performance. Using managed objects should be avoided or used sparingly.

    The method also works for adding managed objects implementing IComponentData, but GetComponentData is the preferred method for those objects.

    GetComponentObject<T>(Entity, ComponentType)

    Gets the managed UnityEngine.Component object from an entity.

    Declaration
    [ExcludeFromBurstCompatTesting("Returns managed object")]
    public T GetComponentObject<T>(Entity entity, ComponentType componentType)
    Parameters
    Type Name Description
    Entity entity

    The entity.

    ComponentType componentType

    The type of the managed object.

    Returns
    Type Description
    T

    The managed object, cast to type T.

    Type Parameters
    Name Description
    T

    The return type of the managed object.

    Remarks

    Accessing data in a managed object forfeits many opportunities for increased performance. Using managed objects should be avoided or used sparingly.

    The method also works for adding managed objects implementing IComponentData, but GetComponentData is the preferred method for those objects.

    GetComponentObject<T>(SystemHandle)

    Gets the managed UnityEngine.Component object from an entity associated with a system.

    Declaration
    [ExcludeFromBurstCompatTesting("Returns managed object")]
    public T GetComponentObject<T>(SystemHandle system)
    Parameters
    Type Name Description
    SystemHandle system

    The system handle.

    Returns
    Type Description
    T

    The managed object, cast to type T.

    Type Parameters
    Name Description
    T

    The type of the managed object.

    Remarks

    Accessing data in a managed object forfeits many opportunities for increased performance. Using managed objects should be avoided or used sparingly.

    The method also works for adding managed objects implementing IComponentData, but GetComponentData is the preferred method for those objects.

    GetComponentObject<T>(SystemHandle, ComponentType)

    Gets the managed UnityEngine.Component object from an entity associated with a system.

    Declaration
    [ExcludeFromBurstCompatTesting("Returns managed object")]
    public T GetComponentObject<T>(SystemHandle system, ComponentType componentType)
    Parameters
    Type Name Description
    SystemHandle system

    The system handle.

    ComponentType componentType

    The type of the managed object.

    Returns
    Type Description
    T

    The managed object, cast to type T.

    Type Parameters
    Name Description
    T

    The return type of the managed object.

    Remarks

    Accessing data in a managed object forfeits many opportunities for increased performance. Using managed objects should be avoided or used sparingly.

    The method also works for adding managed objects implementing IComponentData, but GetComponentData is the preferred method for those objects.

    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)