docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct Entity

    Identifies an entity.

    Namespace: Unity.Entities
    Assembly: Unity.Entities.dll
    Syntax
    public struct Entity
    Remarks

    The entity is a fundamental part of the Entity Component System. Everything in your application that has data or an identity of its own is an entity. However, an entity doesn't contain either data or behavior itself. Instead, the data is stored in the components and the behavior is provided by the systems that process those components. The entity acts as an identifier or key to the data stored in components.

    The EntityManager class manages entities and they exist within a World. An Entity struct refers to an entity, but isn't a reference. Rather, the Entity struct contains an Index that you can use to access entity data, and a Version that you can use to check whether the Index is still valid. Note that you must pass the Index or Version values to
    relevant API methods, rather than accessing them directly.

    To add or remove components, access components, or to destroy the entity, pass an Entity struct to methods of the EntityManager, the EntityCommandBuffer, or the ComponentSystemBase.

    Fields

    Name Description
    Index

    The ID of an entity.

    Version

    The generational version of the entity.

    Properties

    Name Description
    Null

    A "blank" Entity object that does not refer to an actual entity.

    Methods

    Name Description
    CompareTo(Entity)

    Compare this entity against a given one

    Equals(object)

    Entity instances are equal if they refer to the same entity.

    Equals(Entity)

    Entity instances are equal if they represent the same entity.

    GetHashCode()

    A hash used for comparisons.

    ToFixedString()

    Provides a Burst compatible debugging string.

    ToString()

    Provides a debugging string.

    Operators

    Name Description
    operator ==(Entity, Entity)

    Entity instances are equal if they refer to the same entity.

    operator !=(Entity, Entity)

    Entity instances are equal if they refer to the same entity.

    In This Article
    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)