docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method TryGetRefRW

    TryGetRefRW(Entity, out RefRW<T>)

    Attempts to get a safe reference to the component data, failing gracefully if the component isn't present.

    Declaration
    public bool TryGetRefRW(Entity entity, out RefRW<T> outRef)
    Parameters
    Type Name Description
    Entity entity

    The target entity

    RefRW<T> outRef

    The output reference will be stored here. See remarks.

    Returns
    Type Description
    bool

    Returns true if component T exists on entity, or false if it does not.

    Remarks

    If T is a zero-size component, outRef will not contain a valid reference; zero-size components do not have an address in memory. However, this function will still return true or false depending on whether entity has component T.

    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)