docs.unity3d.com
    Show / Hide Table of Contents

    Method GetSharedComponentIndex

    GetSharedComponentIndex<T>(SharedComponentTypeHandle<T>)

    Gets the index into the array of unique values for the specified shared component.

    Declaration
    public int GetSharedComponentIndex<T>(SharedComponentTypeHandle<T> chunkSharedComponentData)
        where T : struct, ISharedComponentData
    Parameters
    Type Name Description
    SharedComponentTypeHandle<T> chunkSharedComponentData

    An object containing type and job safety information. Create this object by calling GetSharedComponentTypeHandle<T>() immediately before scheduling a job. Pass the object to a job using a public field you define as part of the job struct.

    Returns
    Type Description
    Int32

    The index value, or -1 if the chunk does not contain a shared component of the specified type.

    Type Parameters
    Name Description
    T

    The data type of the shared component.

    Remarks

    Because shared components can contain managed types, you can only access the value index of a shared component inside a job, not the value itself. The index value indexes the array returned by GetAllUniqueSharedComponentData<T>(List<T>). If desired, you can create a native array that mirrors your unique value list, but which contains only unmanaged, blittable data and pass that into an IJobChunk job. The unique value list and a specific index is only valid until a structural change occurs.

    GetSharedComponentIndex(DynamicSharedComponentTypeHandle)

    Gets the index into the array of unique values for the specified shared component.

    Declaration
    public int GetSharedComponentIndex(DynamicSharedComponentTypeHandle chunkSharedComponentData)
    Parameters
    Type Name Description
    DynamicSharedComponentTypeHandle chunkSharedComponentData

    An object containing type and job safety information. Create this object by calling GetDynamicSharedComponentTypeHandle(ComponentType).

    Returns
    Type Description
    Int32

    The index value, or -1 if the chunk does not contain a shared component of the specified type.

    Remarks

    Because shared components can contain managed types, you can only access the value index of a shared component inside a job, not the value itself. The index value indexes the array returned by GetAllUniqueSharedComponentData<T>(List<T>). If desired, you can create a native array that mirrors your unique value list, but which contains only unmanaged, blittable data and pass that into an IJobChunk job. The unique value list and a specific index is only valid until a structural change occurs.

    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