# EntityArchetype

> An EntityArchetype is a unique combination of component types. The EntityManager uses the archetype to group all entities that have the same sets of components.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule
* **Implements:** [IEquatable\<EntityArchetype>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct EntityArchetype : IEquatable<EntityArchetype>
```

## Remarks

An entity can change archetype fluidly over its lifespan. For example, when you add or remove components, the archetype of the affected entity changes.

An archetype object is not a container; rather it is an identifier to each unique combination of component types that an application has created at run time, either directly or implicitly.

You can create archetypes directly using [EntityManager.CreateArchetype](/engine/7000.0/script-reference/unity/entities/entitymanager/createarchetype.md). You also implicitly create archetypes whenever you add or remove a component from an entity. An EntityArchetype object is an immutable singleton; creating an archetype with the same set of components, either directly or implicitly, results in the same archetype for a given EntityManager.

The ECS framework uses archetypes to group entities that have the same structure together. The ECS framework stores component data in blocks of memory called "chunks". A given chunk stores only entities having the same archetype. You can get the EntityArchetype object for a chunk from its [ArchetypeChunk.Archetype](/engine/7000.0/script-reference/unity/entities/archetypechunk/archetype.md) property.

Instead of using new EntityArchetype(), use EntityManager.CreateArchetype() to create EntityArchetype values.

## Properties

| Property                                                                                         | Description                                                                              |
| ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
| [ChunkCapacity](/engine/7000.0/script-reference/unity/entities/entityarchetype/chunkcapacity.md) | The number of entities having this archetype that can fit into a single chunk of memory. |
| [ChunkCount](/engine/7000.0/script-reference/unity/entities/entityarchetype/chunkcount.md)       | The current number of chunks storing entities having this archetype.                     |
| [Disabled](/engine/7000.0/script-reference/unity/entities/entityarchetype/disabled.md)           | Reports whether this EntityArchetype instance contains disabled entities.                |
| [Prefab](/engine/7000.0/script-reference/unity/entities/entityarchetype/prefab.md)               | Reports whether this EntityArchetype instance describes a Prefab.                        |
| [StableHash](/engine/7000.0/script-reference/unity/entities/entityarchetype/stablehash.md)       | Retrieve the stable hash for this EntityArchetype.                                       |
| [TypesCount](/engine/7000.0/script-reference/unity/entities/entityarchetype/typescount.md)       | The number of component types this archetype contains.                                   |
| [Valid](/engine/7000.0/script-reference/unity/entities/entityarchetype/valid.md)                 | Reports whether this EntityArchetype instance references a non-null archetype.           |

## Methods

| Method                                                                                                   | Description                                                                           |
| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| [Equals](/engine/7000.0/script-reference/unity/entities/entityarchetype/equals.md)                       | Reports whether this EntityArchetype references the same archetype as another object. |
| [GetComponentTypes](/engine/7000.0/script-reference/unity/entities/entityarchetype/getcomponenttypes.md) | Gets the types of the components making up this archetype.                            |
| [GetHashCode](/engine/7000.0/script-reference/unity/entities/entityarchetype/gethashcode.md)             | Returns the hash of the archetype.                                                    |
| [ToString](/engine/7000.0/script-reference/unity/entities/entityarchetype/tostring.md)                   | Construct a string representation of this archetype, for logging or debugging.        |

## Static Methods

| Method                                                                                                       | Description                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CalculateDifference](/engine/7000.0/script-reference/unity/entities/entityarchetype/calculatedifference.md) | Calculates the difference between two archetypes. Reports what components need to be added to and removed from "before" in order to convert it to "after". |

## Operators

| Operator                                                                                       | Description                             |
| ---------------------------------------------------------------------------------------------- | --------------------------------------- |
| [operator ==](/engine/7000.0/script-reference/unity/entities/entityarchetype/op-equality.md)   | Compares the archetypes for equality.   |
| [operator !=](/engine/7000.0/script-reference/unity/entities/entityarchetype/op-inequality.md) | Compares the archetypes for inequality. |
