Documentation

Unity Engine


Unity Engine


DidChange

Reports whether the data in any of IComponentData components in the chunk, of the type identified by typeHandle, could have changed since the specified version.
Read time 8 minutesLast updated a day ago

Definition

  • Type: Method
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule

DidChange<T>(ComponentTypeHandle<T>, uint)

Reports whether the data in any of IComponentData components in the chunk, of the type identified by
typeHandle
, could have changed since the specified version.
public readonly bool DidChange<T>(ref ComponentTypeHandle<T> typeHandle, uint version) where T : IComponentData

Parameters

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.

version

The version to compare. In a system, this parameter should be set to the current ComponentSystemBase.LastSystemVersion at the time the job is run or scheduled.

Returns

Type

Description

boolTrue, if the version number stored in the chunk for this component is more recent than the version passed to the
version
parameter.

Remarks

When you access a component in a chunk with write privileges, the ECS framework updates the change version of that component type to the current EntityManager.GlobalSystemVersion value. Since every system stores the global system version in its ComponentSystemBase.LastSystemVersion field when it updates, you can compare these two versions with this function in order to determine whether the data of components in this chunk could have changed since the last time that system ran.
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is updated even when another job or system that has declared write access to a component does not actually change the component value.

DidChange(DynamicComponentTypeHandle, uint)

Reports whether the data in any of IComponentData components in the chunk, of the type identified by
typeHandle
, could have changed since the specified version.
public readonly bool DidChange(ref DynamicComponentTypeHandle typeHandle, uint version)

Parameters

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.

version

The version to compare. In a system, this parameter should be set to the current ComponentSystemBase.LastSystemVersion at the time the job is run or scheduled.

Returns

Type

Description

boolTrue, if the version number stored in the chunk for this component is more recent than the version passed to the
version
parameter.

Remarks

When you access a component in a chunk with write privileges, the ECS framework updates the change version of that component type to the current EntityManager.GlobalSystemVersion value. Since every system stores the global system version in its ComponentSystemBase.LastSystemVersion field when it updates, you can compare these two versions with this function in order to determine whether the data of components in this chunk could have changed since the last time that system ran.
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is updated even when another job or system that has declared write access to a component does not actually change the component value.

DidChange<T>(BufferTypeHandle<T>, uint)

Reports whether any of the data in dynamic buffer components in the chunk, of the type identified by
bufferTypeHandle
, could have changed since the specified version.
public readonly bool DidChange<T>(ref BufferTypeHandle<T> bufferTypeHandle, uint version) where T : unmanaged, IBufferElementData

Parameters

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.

version

The version to compare. In a system, this parameter should be set to the current ComponentSystemBase.LastSystemVersion at the time the job is run or scheduled.

Returns

Type

Description

boolTrue, if the version number stored in the chunk for this component is more recent than the version passed to the
version
parameter.

Remarks

When you access a component in a chunk with write privileges, the ECS framework updates the change version of that component type to the current EntityManager.GlobalSystemVersion value. Since every system stores the global system version in its ComponentSystemBase.LastSystemVersion field when it updates, you can compare these two versions with this function in order to determine whether the data of components in this chunk could have changed since the last time that system ran.
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is updated even when another job or system that has declared write access to a component does not actually change the component value.

DidChange(TransformTypeHandle, uint)

Reports whether the TransformRef components in the chunk could have changed since the specified version.
public readonly bool DidChange(ref TransformTypeHandle transformTypeHandle, uint version)

Parameters

transformTypeHandle

An object containing type and job safety information. To create this object, call SystemState.GetTransformTypeHandle. Pass the object to a job using a public field you define as part of the job struct.

version

The version to compare. In a system, this parameter should be set to the current SystemState.LastSystemVersion at the time the job is run or scheduled.

Returns

Type

Description

boolTrue, if the version number stored in the chunk for TransformRef is more recent than the version passed to the
version
parameter.

Remarks

When you access a transform in a chunk with write privileges, the ECS framework updates the change version of TransformRef to the current EntityManager.GlobalSystemVersion value. Since every system stores the global system version in its SystemState.LastSystemVersion field when it updates, you can compare these two versions with this function in order to determine whether the transforms in this chunk could have changed since the last time that system ran.
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is updated even when another job or system that has declared write access to TransformRef does not actually change any transform.

DidChange<T>(SharedComponentTypeHandle<T>, uint)

Reports whether the value of shared components associated with the chunk, of the type identified by
chunkSharedComponentData
, could have changed since the specified version.
public readonly bool DidChange<T>(SharedComponentTypeHandle<T> chunkSharedComponentData, uint version) where T : struct, ISharedComponentData

Parameters

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.

version

The version to compare. In a system, this parameter should be set to the current ComponentSystemBase.LastSystemVersion at the time the job is run or scheduled.

Returns

Type

Description

boolTrue, if the version number stored in the chunk for this component is more recent than the version passed to the
version

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 change version for that chunk is updated. The order version is unaffected.
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is updated even when another job or system that has declared write access to a component does not actually change the component value.

DidChange(DynamicSharedComponentTypeHandle, uint)

Reports whether the value of shared components associated with the chunk, of the type identified by
typeHandle
, could have changed since the specified version.
public readonly bool DidChange(ref DynamicSharedComponentTypeHandle typeHandle, uint version)

Parameters

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

version

The version to compare. In a system, this parameter should be set to the current ComponentSystemBase.LastSystemVersion.

Returns

Type

Description

boolTrue, if the version number stored in the chunk for this component is more recent than the version passed to the
version

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 change version for that chunk is updated. The order version is unaffected.
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is updated even when another job or system that has declared write access to a component does not actually change the component value.