docs.unity3d.com
    Show / Hide Table of Contents

    Method GetChangeVersion

    GetChangeVersion<T>(ComponentTypeHandle<T>)

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

    Declaration
    public uint GetChangeVersion<T>(ComponentTypeHandle<T> chunkComponentTypeHandle)
        where T : IComponentData
    Parameters
    Type Name Description
    ComponentTypeHandle<T> chunkComponentTypeHandle

    An object containing type and job safety information. Create this object by calling GetComponentTypeHandle<T>(Boolean) 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
    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.

    Type Parameters
    Name Description
    T

    The data type of component T.

    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 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)
    • AddChangedVersionFilter(ComponentType)
    • DidChange<T>(ComponentTypeHandle<T>, UInt32) 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.

    GetChangeVersion(DynamicComponentTypeHandle)

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

    Declaration
    public uint GetChangeVersion(DynamicComponentTypeHandle chunkComponentType)
    Parameters
    Type Name Description
    DynamicComponentTypeHandle chunkComponentType

    An object containing type and job safety information. Create this object by calling GetDynamicComponentTypeHandle(ComponentType) 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
    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 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)
    • AddChangedVersionFilter(ComponentType)
    • DidChange<T>(ComponentTypeHandle<T>, UInt32) 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.

    GetChangeVersion<T>(BufferTypeHandle<T>)

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

    Declaration
    public uint GetChangeVersion<T>(BufferTypeHandle<T> chunkBufferTypeHandle)
        where T : struct, IBufferElementData
    Parameters
    Type Name Description
    BufferTypeHandle<T> chunkBufferTypeHandle

    An object containing type and job safety information. Create this object by calling GetBufferTypeHandle<T>(Boolean) 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
    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.

    Type Parameters
    Name Description
    T

    The data type of component T.

    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 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)
    • AddChangedVersionFilter(ComponentType)
    • DidChange<T>(ComponentTypeHandle<T>, UInt32) 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.

    GetChangeVersion<T>(SharedComponentTypeHandle<T>)

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

    Declaration
    public uint GetChangeVersion<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
    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.

    Type Parameters
    Name Description
    T

    The data type of shared component T.

    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.

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

    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