docs.unity.cn
    Show / Hide Table of Contents

    Method GetSharedComponentData

    GetSharedComponentData<T>(Entity)

    Gets a shared component from an entity.

    Declaration
    [NotBurstCompatible]
    public T GetSharedComponentData<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.

    GetSharedComponentData<T>(Int32)

    Gets a shared component by index.

    Declaration
    [NotBurstCompatible]
    public T GetSharedComponentData<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 GetAllUniqueSharedComponentData<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 © 2022 Unity Technologies
    Generated by DocFX
    on 04 August 2022
    Terms of use