docs.unity.cn
    Show / Hide Table of Contents

    Method GetSharedComponentManaged

    GetSharedComponentManaged<T>(Entity)

    Gets a shared component from an entity.

    Declaration
    [ExcludeFromBurstCompatTesting("Accesses managed component store")]
    public T GetSharedComponentManaged<T>(Entity entity)
        where T : struct, ISharedComponentData
    Parameters
    Type Name Description
    Entity entity

    The entity.

    Returns
    Type Description
    T

    A copy of the shared component.

    Type Parameters
    Name Description
    T

    The type of shared component.

    GetSharedComponentManaged<T>(Int32)

    Gets a shared component by index.

    Declaration
    [ExcludeFromBurstCompatTesting("Accesses managed component store")]
    public T GetSharedComponentManaged<T>(int sharedComponentIndex)
        where T : struct, ISharedComponentData
    Parameters
    Type Name Description
    Int32 sharedComponentIndex

    The index of the shared component in the internal shared component list.

    Returns
    Type Description
    T

    A copy of the shared component.

    Type Parameters
    Name Description
    T

    The data type of the shared component.

    Remarks

    The ECS framework maintains an internal list of unique shared components. You can get the components in this list, along with their indices using GetAllUniqueSharedComponentsManaged<T>(List<T>, List<Int32>). An index in the list is valid and points to the same shared component index as long as the shared component order version from GetSharedComponentOrderVersion<T>(T) remains the same.

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023