docs.unity3d.com
    Show / Hide Table of Contents

    Method TryGetComponent

    TryGetComponent(Entity, out T)

    Retrieves the component associated with the specified Entity, if it exists. Then reports if the instance still refers to a valid entity and that it has a component of type T.

    Declaration
    public bool TryGetComponent(Entity entity, out T componentData)
    Parameters
    Type Name Description
    Entity entity

    The entity.

    T componentData

    The component of type T for the given entity, if it exists.

    Returns
    Type Description
    Boolean

    True if the entity has a component of type T, and false if it does not.

    Remarks

    To report if the provided entity has a component of type T, this function confirms whether the EntityArchetype of the provided entity includes components of type T.

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023