# GetChangeVersion

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

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## GetChangeVersion\<T>(ComponentTypeHandle\<T>)

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

```csharp
public readonly uint GetChangeVersion<T>(ref ComponentTypeHandle<T> typeHandle) where T : IComponentData
```

### Parameters

**** (\[ComponentTypeHandle\<T>]\(/engine/7000.0/script-reference/unity/entities/componenttypehandle1)): An object containing type and job safety information. To create this object, call [ComponentSystemBase.GetComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/componentsystembase/getcomponenttypehandle.md). Pass the object to a job using a public field you define as part of the job struct.

### Returns

| Type                                                         | Description                                                                                                                                                                                                                                              |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | 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. |

### Remarks

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](/engine/7000.0/script-reference/unity/entities/componentsystembase/globalsystemversion.md). (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](/engine/7000.0/script-reference/unity/entities/entityquery/addchangedversionfilter.md)

* [ArchetypeChunk.DidChange](/engine/7000.0/script-reference/unity/entities/archetypechunk/didchange.md) in an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) 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.

## GetChangeVersion(DynamicComponentTypeHandle)

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

```csharp
public readonly uint GetChangeVersion(ref DynamicComponentTypeHandle typeHandle)
```

### Parameters

**** (\[DynamicComponentTypeHandle]\(/engine/7000.0/script-reference/unity/entities/dynamiccomponenttypehandle)): An object containing type and job safety information. To create this object, call [ComponentSystemBase.GetDynamicComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/componentsystembase/getdynamiccomponenttypehandle.md). Pass the object to a job using a public field you define as part of the job struct.

### Returns

| Type                                                         | Description                                                                                                                                                                                                                                              |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | 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. |

### Remarks

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](/engine/7000.0/script-reference/unity/entities/componentsystembase/globalsystemversion.md). (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](/engine/7000.0/script-reference/unity/entities/entityquery/addchangedversionfilter.md)

* [ArchetypeChunk.DidChange](/engine/7000.0/script-reference/unity/entities/archetypechunk/didchange.md) in an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) 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.

## GetChangeVersion\<T>(BufferTypeHandle\<T>)

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

```csharp
public readonly uint GetChangeVersion<T>(ref BufferTypeHandle<T> bufferTypeHandle) where T : unmanaged, IBufferElementData
```

### Parameters

**** (\[BufferTypeHandle\<T>]\(/engine/7000.0/script-reference/unity/entities/buffertypehandle1)): An object containing type and job safety information. To create this object, call [ComponentSystemBase.GetBufferTypeHandle](/engine/7000.0/script-reference/unity/entities/componentsystembase/getbuffertypehandle.md). Pass the object to a job using a public field you define as part of the job struct.

### Returns

| Type                                                         | Description                                                                                                                                                                                                                                                                      |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | 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. |

### Remarks

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](/engine/7000.0/script-reference/unity/entities/componentsystembase/globalsystemversion.md). (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](/engine/7000.0/script-reference/unity/entities/entityquery/addchangedversionfilter.md)

* [ArchetypeChunk.DidChange](/engine/7000.0/script-reference/unity/entities/archetypechunk/didchange.md) in an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) 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.

## GetChangeVersion(TransformTypeHandle)

Gets the change version number assigned to [TransformRef](/engine/7000.0/script-reference/unity/entities/transformref.md) in this chunk.

```csharp
public readonly uint GetChangeVersion(ref TransformTypeHandle transformTypeHandle)
```

### Parameters

**** (\[TransformTypeHandle]\(/engine/7000.0/script-reference/unity/entities/transformtypehandle)): An object containing type and job safety information. To create this object, call [SystemState.GetTransformTypeHandle](/engine/7000.0/script-reference/unity/entities/systemstate/gettransformtypehandle.md). Pass the object to a job using a public field you define as part of the job struct.

### Returns

| Type                                                         | Description                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | The current version number of [TransformRef](/engine/7000.0/script-reference/unity/entities/transformref.md), which is the version set the last time a system accessed a transform in this chunk with write privileges. Returns 0 if the chunk does not contain [TransformRef](/engine/7000.0/script-reference/unity/entities/transformref.md). |

### Remarks

Every time a system accesses transforms in a chunk, the system updates the change version of [TransformRef](/engine/7000.0/script-reference/unity/entities/transformref.md) if it has write access, with the current [SystemState.GlobalSystemVersion](/engine/7000.0/script-reference/unity/entities/systemstate/globalsystemversion.md). (A system updates the version whether or not you actually write any transform data -- always specify read-only access when possible.)

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

* [EntityQuery.AddChangedVersionFilter](/engine/7000.0/script-reference/unity/entities/entityquery/addchangedversionfilter.md)

* [ArchetypeChunk.DidChange](/engine/7000.0/script-reference/unity/entities/archetypechunk/didchange.md) in an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) 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.

## GetChangeVersion\<T>(SharedComponentTypeHandle\<T>)

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

```csharp
public readonly uint GetChangeVersion<T>(SharedComponentTypeHandle<T> chunkSharedComponentData) where T : struct, ISharedComponentData
```

### Parameters

**** (\[SharedComponentTypeHandle\<T>]\(/engine/7000.0/script-reference/unity/entities/sharedcomponenttypehandle1)): An object containing type and job safety information. To create this object, call [ComponentSystemBase.GetSharedComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/componentsystembase/getsharedcomponenttypehandle.md). Pass the object to a job using a public field you define as part of the job struct.

### Returns

| Type                                                         | Description                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | 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. |

### Remarks

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.

## GetChangeVersion(DynamicSharedComponentTypeHandle)

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

```csharp
public readonly uint GetChangeVersion(ref DynamicSharedComponentTypeHandle typeHandle)
```

### Parameters

**** (\[DynamicSharedComponentTypeHandle]\(/engine/7000.0/script-reference/unity/entities/dynamicsharedcomponenttypehandle)): An object containing type and job safety information. To create this object, call [ComponentSystemBase.GetDynamicSharedComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/componentsystembase/getdynamicsharedcomponenttypehandle.md).

### Returns

| Type                                                         | Description                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | 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. |

### Remarks

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.
