docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct 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.

    Namespace: Unity.Entities
    Assembly: Unity.Entities.dll
    Syntax
    public struct 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 CreateArchetype(params ComponentType[]). 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 Archetype property.

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

    Properties

    Name Description
    ChunkCapacity

    The number of entities having this archetype that can fit into a single chunk of memory.

    ChunkCount

    The current number of chunks storing entities having this archetype.

    Disabled

    Reports whether this EntityArchetype instance contains disabled entities.

    Prefab

    Reports whether this EntityArchetype instance describes a Prefab.

    StableHash

    Retrieve the stable hash for this EntityArchetype.

    TypesCount

    The number of component types this archetype contains.

    Valid

    Reports whether this EntityArchetype instance references a non-null archetype.

    Methods

    Name Description
    CalculateDifference(EntityArchetype, EntityArchetype, TypeIndex*, out int, TypeIndex*, out int)

    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".

    Equals(object)

    Reports whether this EntityArchetype references the same archetype as another object.

    Equals(EntityArchetype)

    Compares archetypes for equality.

    GetComponentTypes(Allocator)

    Gets the types of the components making up this archetype.

    GetComponentTypes(AllocatorHandle)

    Gets the types of the components making up this archetype.

    GetHashCode()

    Returns the hash of the archetype.

    ToString()

    Construct a string representation of this archetype, for logging or debugging.

    Operators

    Name Description
    operator ==(EntityArchetype, EntityArchetype)

    Compares the archetypes for equality.

    operator !=(EntityArchetype, EntityArchetype)

    Compares the archetypes for inequality.


    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
    • Properties
    • Methods
    • Operators
    Back to top
    Copyright © 2025 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)