docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method GetChangeVersion

    GetChangeVersion<T>(ref ComponentTypeHandle<T>)

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

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

    An object containing type and job safety information. To create this object, call GetComponentTypeHandle<T>(bool). Pass the object to a job using a public field you define as part of the job struct.

    Returns
    Type Description
    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.

    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>(ref ComponentTypeHandle<T>, uint) 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>(ComponentTypeHandle<T>)

    Obsolete. Use GetChangeVersion<T>(ref ComponentTypeHandle<T>) instead.

    Declaration
    [Obsolete("The typeHandle argument should now be passed by ref. (RemovedAfter Entities 1.0)", false)]
    public readonly uint GetChangeVersion<T>(ComponentTypeHandle<T> typeHandle) where T : IComponentData
    Parameters
    Type Name Description
    ComponentTypeHandle<T> typeHandle

    An object containing type and job safety information. To create this object, call GetComponentTypeHandle<T>(bool). Pass the object to a job using a public field you define as part of the job struct.

    Returns
    Type Description
    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.

    Type Parameters
    Name Description
    T

    The data type of component T.

    GetChangeVersion(ref DynamicComponentTypeHandle)

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

    Declaration
    public readonly uint GetChangeVersion(ref DynamicComponentTypeHandle typeHandle)
    Parameters
    Type Name Description
    DynamicComponentTypeHandle typeHandle

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

    Returns
    Type Description
    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.

    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>(ref ComponentTypeHandle<T>, uint) 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)

    Obsolete. Use GetChangeVersion(ref DynamicComponentTypeHandle) instead.

    Declaration
    [Obsolete("The typeHandle argument should now be passed by ref. (RemovedAfter Entities 1.0)", false)]
    public readonly uint GetChangeVersion(DynamicComponentTypeHandle typeHandle)
    Parameters
    Type Name Description
    DynamicComponentTypeHandle typeHandle

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

    Returns
    Type Description
    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.

    GetChangeVersion<T>(ref BufferTypeHandle<T>)

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

    Declaration
    public readonly uint GetChangeVersion<T>(ref BufferTypeHandle<T> bufferTypeHandle) where T : unmanaged, IBufferElementData
    Parameters
    Type Name Description
    BufferTypeHandle<T> bufferTypeHandle

    An object containing type and job safety information. To create this object, call GetBufferTypeHandle<T>(bool). Pass the object to a job using a public field you define as part of the job struct.

    Returns
    Type Description
    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.

    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>(ref ComponentTypeHandle<T>, uint) 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>(BufferTypeHandle<T>)

    Obsolete. Use GetChangeVersion<T>(ref BufferTypeHandle<T>) instead.

    Declaration
    [Obsolete("The bufferTypeHandle argument should now be passed by ref. (RemovedAfter Entities 1.0)", false)]
    public readonly uint GetChangeVersion<T>(BufferTypeHandle<T> bufferTypeHandle) where T : unmanaged, IBufferElementData
    Parameters
    Type Name Description
    BufferTypeHandle<T> bufferTypeHandle

    An object containing type and job safety information. To create this object, call GetBufferTypeHandle<T>(bool). Pass the object to a job using a public field you define as part of the job struct.

    Returns
    Type Description
    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.

    Type Parameters
    Name Description
    T

    The data type of component T.

    GetChangeVersion<T>(SharedComponentTypeHandle<T>)

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

    Declaration
    public readonly 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. To create this object, call GetSharedComponentTypeHandle<T>(). Pass the object to a job using a public field you define as part of the job struct.

    Returns
    Type Description
    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.

    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(ref DynamicSharedComponentTypeHandle)

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

    Declaration
    public readonly uint GetChangeVersion(ref DynamicSharedComponentTypeHandle typeHandle)
    Parameters
    Type Name Description
    DynamicSharedComponentTypeHandle typeHandle

    An object containing type and job safety information. To create this object, call GetDynamicSharedComponentTypeHandle(ComponentType).

    Returns
    Type Description
    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.

    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)

    Obsolete. Use GetChangeVersion(ref DynamicSharedComponentTypeHandle) instead.

    Declaration
    [Obsolete("The typeHandle argument should now be passed by ref. (RemovedAfter Entities 1.0)", false)]
    public readonly uint GetChangeVersion(DynamicSharedComponentTypeHandle typeHandle)
    Parameters
    Type Name Description
    DynamicSharedComponentTypeHandle typeHandle

    An object containing type and job safety information. To create this object, call GetDynamicSharedComponentTypeHandle(ComponentType).

    Returns
    Type Description
    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.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • GetChangeVersion<T>(ref ComponentTypeHandle<T>)
    • GetChangeVersion<T>(ComponentTypeHandle<T>)
    • GetChangeVersion(ref DynamicComponentTypeHandle)
    • GetChangeVersion(DynamicComponentTypeHandle)
    • GetChangeVersion<T>(ref BufferTypeHandle<T>)
    • GetChangeVersion<T>(BufferTypeHandle<T>)
    • GetChangeVersion<T>(SharedComponentTypeHandle<T>)
    • GetChangeVersion(ref DynamicSharedComponentTypeHandle)
    • GetChangeVersion(DynamicSharedComponentTypeHandle)
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)