docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method GetCompanion

    GetCompanion<T>(EntityManager, Entity)

    Returns the UnityEngine.Component of type T referenced by the entity's companion component.

    Declaration
    public static T GetCompanion<T>(this EntityManager entityManager, Entity entity) where T : Component
    Parameters
    Type Name Description
    EntityManager entityManager

    The entity manager that stores entity.

    Entity entity

    The entity to read the companion component from.

    Returns
    Type Description
    T

    The T component referenced by the entity's CompanionComponent<T>.

    Type Parameters
    Name Description
    T
    Remarks

    Resolving the reference is a managed call, so call this method from the main thread. Throws if entity has no CompanionComponent<T>.

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