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

ArchetypeChunk.GetChangeVersion

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 uint GetChangeVersion(ref ComponentTypeHandle`1 typeHandle);

Parameters

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

Returns

uint The current version number of the specified component, which is the version set the last time a system accessed a component of that type in this chunk with write privileges. Returns 0 if the chunk does not contain a component of the specified type.

Description

Gets the change version number assigned to the specified type of component in this chunk.

Every time a system accesses components in a chunk, the system updates the change version of any component types to which it has write access with the current ComponentSystemBase.GlobalSystemVersion. (A system updates the version whether or not you actually write any component data -- always specify read-only access when possible.)

You can use the change version to filter out entities that have not changed since the last time a system ran. Implement change filtering using one of the following:

- Entities.ForEach.WithChangeFilter(ComponentType)
- EntityQuery.AddChangedVersionFilter
- ArchetypeChunk.DidChange in an IJobChunk job.


Note that change versions are stored at the chunk level. Thus when you use change filtering, the query system excludes or includes whole chunks not individual entities.


Declaration

public uint GetChangeVersion(ref DynamicComponentTypeHandle typeHandle);

Parameters

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

Returns

uint The current version number of the specified component, which is the version set the last time a system accessed a component of that type in this chunk with write privileges. Returns 0 if the chunk does not contain a component of the specified type.

Description

Gets the change version number assigned to the specified type of component in this chunk.

Every time a system accesses components in a chunk, the system updates the change version of any component types to which it has write access with the current ComponentSystemBase.GlobalSystemVersion. (A system updates the version whether or not you actually write any component data -- always specify read-only access when possible.)

You can use the change version to filter out entities that have not changed since the last time a system ran. Implement change filtering using one of the following:

- Entities.ForEach.WithChangeFilter(ComponentType)
- EntityQuery.AddChangedVersionFilter
- ArchetypeChunk.DidChange in an IJobChunk job.


Note that change versions are stored at the chunk level. Thus when you use change filtering, the query system excludes or includes whole chunks not individual entities.


Declaration

public uint GetChangeVersion(ref BufferTypeHandle`1 bufferTypeHandle);

Parameters

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

Returns

uint The current version number of the specified dynamic buffer type, which is the version set the last time a system accessed a buffer component of that type in this chunk with write privileges. Returns 0 if the chunk does not contain a buffer component of the specified type.

Description

Gets the change version number assigned to the specified type of dynamic buffer component in this chunk.

Every time a system accesses components in a chunk, the system updates the change version of any component types to which it has write access with the current ComponentSystemBase.GlobalSystemVersion. (A system updates the version whether or not you actually write any component data -- always specify read-only access when possible.)

You can use the change version to filter out entities that have not changed since the last time a system ran. Implement change filtering using one of the following:

- Entities.ForEach.WithChangeFilter(ComponentType)
- EntityQuery.AddChangedVersionFilter
- ArchetypeChunk.DidChange in an IJobChunk job.


Note that change versions are stored at the chunk level. Thus if you use change filtering, the query system excludes or includes whole chunks not individual entities.


Declaration

public uint GetChangeVersion(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

uint The current version number of the specified shared component, which is the version set the last time a system accessed a component of that type in this chunk with write privileges. Returns 0 if the chunk does not contain a shared component of the specified type.

Description

Gets the change version number assigned to the specified type of shared component in this chunk.

Shared components behave differently than other types of components in terms of change versioning because changing the value of a shared component can move an entity to a different chunk. If the change results in an entity moving to a different chunk, then only the order version is updated (for both the original and the receiving chunk). If you change the shared component value for all entities in a chunk at once, the entities remain in their current chunk. The change version for that chunk is updated and the order version is unaffected.


Declaration

public uint GetChangeVersion(ref DynamicSharedComponentTypeHandle typeHandle);

Parameters

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

Returns

uint The current version number of the specified shared component, which is the version set the last time a system accessed a component of that type in this chunk with write privileges. Returns 0 if the chunk does not contain a shared component of the specified type.

Description

Gets the change version number assigned to the specified type of shared component in this chunk.

Shared components behave differently than other types of components in terms of change versioning because changing the value of a shared component can move an entity to a different chunk. If the change results in an entity moving to a different chunk, then only the order version is updated (for both the original and the receiving chunk). If you change the shared component value for all entities in a chunk at once, the entities remain in their current chunk. The change version for that chunk is updated and the order version is unaffected.