Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

ArchetypeChunk.GetSharedComponentIndex

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public int GetSharedComponentIndex(SharedComponentTypeHandle<T> chunkSharedComponentData);

Parameters

Parameter Description
chunkSharedComponentData An object containing type and job safety information. To create this object, call ComponentSystemBase.GetSharedComponentTypeHandle. Pass the object to a job using a public field you define as part of the job struct.

Returns

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

Description

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

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 EntityManager.GetAllUniqueSharedComponents. 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.


Declaration

public int GetSharedComponentIndex(ref DynamicSharedComponentTypeHandle typeHandle);

Parameters

Parameter Description
typeHandle An object containing type and job safety information. To create this object, call ComponentSystemBase.GetDynamicSharedComponentTypeHandle.

Returns

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

Description

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

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 EntityManager.GetAllUniqueSharedComponents. 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.