Struct ArchetypeChunk
A block of unmanaged memory containing the components for entities sharing the same Unity.Entities.Archetype.
Namespace: Unity.Entities
Syntax
public struct ArchetypeChunk : IEquatable<ArchetypeChunk>
Properties
Archetype
The archetype of the entities stored in this chunk.
Declaration
public EntityArchetype Archetype { get; }
Property Value
Type | Description |
---|---|
EntityArchetype |
Remarks
All entities in a chunk must have the same Unity.Entities.Archetype.
Capacity
The number of entities that can fit in this chunk.
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
The capacity of a chunk depends on the size of the components making up the Unity.Entities.Archetype of the entities stored in the chunk.
Count
The number of entities currently stored in the chunk.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Full
Whether this chunk is exactly full.
Declaration
public bool Full { get; }
Property Value
Type | Description |
---|---|
Boolean |
Null
A special "null" ArchetypeChunk that you can use to test whether ArchetypeChunk instances are valid.
Declaration
public static ArchetypeChunk Null { get; }
Property Value
Type | Description |
---|---|
ArchetypeChunk |
Remarks
An ArchetypeChunk struct that refers to a chunk of memory that has been freed will be equal to this "null" ArchetypeChunk instance.
Methods
DidChange(ArchetypeChunkComponentTypeDynamic, UInt32)
Reports whether any of IComponentData components in the chunk, of the type identified by
chunkComponentType
, could have changed.
Declaration
public bool DidChange(ArchetypeChunkComponentTypeDynamic chunkComponentType, uint version)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentTypeDynamic | chunkComponentType | An object containing type and job safety information. Create this
object by calling |
UInt32 | version | The version to compare. In a system, this parameter should be set to the current LastSystemVersion at the time the job is run or scheduled. |
Returns
Type | Description |
---|---|
Boolean | True, if the version number stored in the chunk for this component is more recent than the version
passed to the |
Remarks
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is incremented even when another job or system that has declared write access to a component does not actually change the component value.
DidChange<T>(ArchetypeChunkBufferType<T>, UInt32)
Reports whether any of dynamic buffer components in the chunk, of the type identified by
chunkBufferType
, could have changed.
Declaration
public bool DidChange<T>(ArchetypeChunkBufferType<T> chunkBufferType, uint version)
where T : struct, IBufferElementData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkBufferType<T> | chunkBufferType | An object containing type and job safety information. Create this
object by calling |
UInt32 | version | The version to compare. In a system, this parameter should be set to the current LastSystemVersion at the time the job is run or scheduled. |
Returns
Type | Description |
---|---|
Boolean | True, if the version number stored in the chunk for this component is more recent than the version
passed to the |
Type Parameters
Name | Description |
---|---|
T | The data type of the elements in the dynamic buffer. |
Remarks
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is incremented even when another job or system that has declared write access to a component does not actually change the component value.
DidChange<T>(ArchetypeChunkComponentType<T>, UInt32)
Reports whether any of IComponentData components in the chunk, of the type identified by
chunkComponentType
, could have changed.
Declaration
public bool DidChange<T>(ArchetypeChunkComponentType<T> chunkComponentType, uint version)
where T : IComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | chunkComponentType | An object containing type and job safety information. Create this
object by calling |
UInt32 | version | The version to compare. In a system, this parameter should be set to the current LastSystemVersion at the time the job is run or scheduled. |
Returns
Type | Description |
---|---|
Boolean | True, if the version number stored in the chunk for this component is more recent than the version
passed to the |
Type Parameters
Name | Description |
---|---|
T | The component type. |
Remarks
Note that for efficiency, the change version applies to whole chunks not individual entities. The change version is incremented even when another job or system that has declared write access to a component does not actually change the component value.
DidChange<T>(ArchetypeChunkSharedComponentType<T>, UInt32)
Declaration
public bool DidChange<T>(ArchetypeChunkSharedComponentType<T> chunkSharedComponentData, uint version)
where T : struct, ISharedComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkSharedComponentType<T> | chunkSharedComponentData | |
UInt32 | version |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T |
Equals(Object)
Two ArchetypeChunk instances are equal if they reference the same block of chunk memory.
Declaration
public override bool Equals(object compare)
Parameters
Type | Name | Description |
---|---|---|
Object | compare | An object |
Returns
Type | Description |
---|---|
Boolean | True if |
Overrides
Equals(ArchetypeChunk)
Two ArchetypeChunk instances are equal if they reference the same block of chunk memory.
Declaration
public bool Equals(ArchetypeChunk archetypeChunk)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunk | archetypeChunk | Another ArchetypeChunk instance |
Returns
Type | Description |
---|---|
Boolean | True, if both ArchetypeChunk instances reference the same memory or both contain null memory references. |
GetBufferAccessor<T>(ArchetypeChunkBufferType<T>)
Declaration
public BufferAccessor<T> GetBufferAccessor<T>(ArchetypeChunkBufferType<T> bufferComponentType)
where T : struct, IBufferElementData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkBufferType<T> | bufferComponentType |
Returns
Type | Description |
---|---|
BufferAccessor<T> |
Type Parameters
Name | Description |
---|---|
T |
GetChangeVersion(ArchetypeChunkComponentTypeDynamic)
Returns a version number that increases whenever read-write access to the given component is requested from this chunk, or 0 if the component doesn't exist in the chunk.
Declaration
public uint GetChangeVersion(ArchetypeChunkComponentTypeDynamic chunkComponentType)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentTypeDynamic | chunkComponentType |
Returns
Type | Description |
---|---|
UInt32 | Current version number of the given component |
GetChunkComponentData<T>(ArchetypeChunkComponentType<T>)
Declaration
public T GetChunkComponentData<T>(ArchetypeChunkComponentType<T> chunkComponentType)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | chunkComponentType |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
GetComponentObjects<T>(ArchetypeChunkComponentType<T>, EntityManager)
Declaration
public ArchetypeChunkComponentObjects<T> GetComponentObjects<T>(ArchetypeChunkComponentType<T> componentType, EntityManager manager)
where T : class
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | componentType | |
EntityManager | manager |
Returns
Type | Description |
---|---|
ArchetypeChunkComponentObjects<T> |
Type Parameters
Name | Description |
---|---|
T |
GetComponentVersion<T>(ArchetypeChunkBufferType<T>)
Declaration
public uint GetComponentVersion<T>(ArchetypeChunkBufferType<T> chunkBufferType)
where T : struct, IBufferElementData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkBufferType<T> | chunkBufferType |
Returns
Type | Description |
---|---|
UInt32 |
Type Parameters
Name | Description |
---|---|
T |
GetComponentVersion<T>(ArchetypeChunkComponentType<T>)
Declaration
public uint GetComponentVersion<T>(ArchetypeChunkComponentType<T> chunkComponentType)
where T : IComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | chunkComponentType |
Returns
Type | Description |
---|---|
UInt32 |
Type Parameters
Name | Description |
---|---|
T |
GetComponentVersion<T>(ArchetypeChunkSharedComponentType<T>)
Declaration
public uint GetComponentVersion<T>(ArchetypeChunkSharedComponentType<T> chunkSharedComponentData)
where T : struct, ISharedComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkSharedComponentType<T> | chunkSharedComponentData |
Returns
Type | Description |
---|---|
UInt32 |
Type Parameters
Name | Description |
---|---|
T |
GetDynamicComponentDataArrayReinterpret<T>(ArchetypeChunkComponentTypeDynamic, Int32)
Declaration
public NativeArray<T> GetDynamicComponentDataArrayReinterpret<T>(ArchetypeChunkComponentTypeDynamic chunkComponentType, int expectedTypeSize)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentTypeDynamic | chunkComponentType | |
Int32 | expectedTypeSize |
Returns
Type | Description |
---|---|
NativeArray<T> |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
ArgumentException | |
InvalidOperationException |
GetHashCode()
Computes a hashcode to support hash-based collections.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The computed hash. |
Overrides
GetNativeArray(ArchetypeChunkEntityType)
Provides a native array interface to entity instances stored in this chunk.
Declaration
public NativeArray<Entity> GetNativeArray(ArchetypeChunkEntityType archetypeChunkEntityType)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkEntityType | archetypeChunkEntityType | An object containing type and job safety information. Create this
object by calling |
Returns
Type | Description |
---|---|
NativeArray<Entity> | A native array containing the entities in the chunk. |
Remarks
The native array returned by this method references existing data, not a copy.
GetNativeArray<T>(ArchetypeChunkComponentType<T>)
Provides a native array interface to components stored in this chunk.
Declaration
public NativeArray<T> GetNativeArray<T>(ArchetypeChunkComponentType<T> chunkComponentType)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | chunkComponentType | An object containing type and job safety information. Create this
object by calling |
Returns
Type | Description |
---|---|
NativeArray<T> | A native array containing the components in the chunk. |
Type Parameters
Name | Description |
---|---|
T | The data type of the component. |
Remarks
The native array returned by this method references existing data, not a copy.
Exceptions
Type | Condition |
---|---|
ArgumentException | If you call this function on a "tag" component type (which is an empty component with no fields). |
GetSharedComponentData<T>(ArchetypeChunkSharedComponentType<T>, EntityManager)
Declaration
public T GetSharedComponentData<T>(ArchetypeChunkSharedComponentType<T> chunkSharedComponentData, EntityManager entityManager)
where T : struct, ISharedComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkSharedComponentType<T> | chunkSharedComponentData | |
EntityManager | entityManager |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
GetSharedComponentIndex<T>(ArchetypeChunkSharedComponentType<T>)
Declaration
public int GetSharedComponentIndex<T>(ArchetypeChunkSharedComponentType<T> chunkSharedComponentData)
where T : struct, ISharedComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkSharedComponentType<T> | chunkSharedComponentData |
Returns
Type | Description |
---|---|
Int32 |
Type Parameters
Name | Description |
---|---|
T |
Has(ArchetypeChunkComponentTypeDynamic)
Declaration
public bool Has(ArchetypeChunkComponentTypeDynamic chunkComponentType)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentTypeDynamic | chunkComponentType |
Returns
Type | Description |
---|---|
Boolean |
Has<T>(ArchetypeChunkBufferType<T>)
Reports whether this chunk contains a dynamic buffer containing the specified component type.
Declaration
public bool Has<T>(ArchetypeChunkBufferType<T> chunkBufferType)
where T : struct, IBufferElementData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkBufferType<T> | chunkBufferType | An object containing type and job safety information. Create this
object by calling |
Returns
Type | Description |
---|---|
Boolean | True, if this chunk contains an array of the dynamic buffers containing the specified component type. |
Type Parameters
Name | Description |
---|---|
T | The data type of the component stored in the dynamic buffer. |
Remarks
When an EntityQuery includes optional dynamic buffer types (with Any), some chunks returned by the query may have these dynamic buffers components and some may not. Use this function to determine whether or not the current chunk contains one of these optional dynamic buffers.
Has<T>(ArchetypeChunkComponentType<T>)
Reports whether this chunk contains the specified component type.
Declaration
public bool Has<T>(ArchetypeChunkComponentType<T> chunkComponentType)
where T : IComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | chunkComponentType | An object containing type and job safety information. Create this
object by calling |
Returns
Type | Description |
---|---|
Boolean | True, if this chunk contains an array of the specified component type. |
Type Parameters
Name | Description |
---|---|
T | The data type of the component. |
Remarks
When an EntityQuery includes optional components (using Any), some chunks returned by the query may contain such components and some may not. Use this function to determine whether or not the current chunk contains one of these optional component types.
Has<T>(ArchetypeChunkSharedComponentType<T>)
Reports whether this chunk contains a shared component of the specified component type.
Declaration
public bool Has<T>(ArchetypeChunkSharedComponentType<T> chunkComponentType)
where T : struct, ISharedComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkSharedComponentType<T> | chunkComponentType | An object containing type and job safety information. Create this
object by calling |
Returns
Type | Description |
---|---|
Boolean | True, if this chunk contains a shared component of the specified type. |
Type Parameters
Name | Description |
---|---|
T | The data type of the shared component. |
Remarks
When an EntityQuery includes optional components used as shared components (with Any), some chunks returned by the query may have these shared components and some may not. Use this function to determine whether or not the current chunk contains one of these optional component types as a shared component.
HasChunkComponent<T>(ArchetypeChunkComponentType<T>)
Reports whether this chunk contains a chunk component of the specified component type.
Declaration
public bool HasChunkComponent<T>(ArchetypeChunkComponentType<T> chunkComponentType)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | chunkComponentType | An object containing type and job safety information. Create this
object by calling |
Returns
Type | Description |
---|---|
Boolean | True, if this chunk contains a chunk component of the specified type. |
Type Parameters
Name | Description |
---|---|
T | The data type of the chunk component. |
Remarks
When an EntityQuery includes optional components used as chunk components (with Any), some chunks returned by the query may have these chunk components and some may not. Use this function to determine whether or not the current chunk contains one of these optional component types as a chunk component.
Invalid()
Reports whether this ArchetypeChunk instance is invalid.
Declaration
public bool Invalid()
Returns
Type | Description |
---|---|
Boolean | True, if no Unity.Entities.Archetype is associated with the this ArchetypeChunk instance. |
Locked()
Reports whether this ArchetypeChunk is locked.
Declaration
public bool Locked()
Returns
Type | Description |
---|---|
Boolean | True, if locked. |
See Also
NumSharedComponents()
The number of shared components in the archetype associated with this chunk.
Declaration
public int NumSharedComponents()
Returns
Type | Description |
---|---|
Int32 | The shared component count. |
SetChunkComponentData<T>(ArchetypeChunkComponentType<T>, T)
Declaration
public void SetChunkComponentData<T>(ArchetypeChunkComponentType<T> chunkComponentType, T value)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunkComponentType<T> | chunkComponentType | |
T | value |
Type Parameters
Name | Description |
---|---|
T |
Operators
Equality(ArchetypeChunk, ArchetypeChunk)
Two ArchetypeChunk instances are equal if they reference the same block of chunk memory.
Declaration
public static bool operator ==(ArchetypeChunk lhs, ArchetypeChunk rhs)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunk | lhs | An ArchetypeChunk |
ArchetypeChunk | rhs | Another ArchetypeChunk |
Returns
Type | Description |
---|---|
Boolean | True, if both ArchetypeChunk instances reference the same memory, or both contain null memory references. |
Inequality(ArchetypeChunk, ArchetypeChunk)
Two ArchetypeChunk instances are only equal if they reference the same block of chunk memory.
Declaration
public static bool operator !=(ArchetypeChunk lhs, ArchetypeChunk rhs)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunk | lhs | An ArchetypeChunk |
ArchetypeChunk | rhs | Another ArchetypeChunk |
Returns
Type | Description |
---|---|
Boolean | True, if the ArchetypeChunk instances reference different blocks of memory. |