docs.unity.cn
    Show / Hide Table of Contents

    Struct Entity

    Identifies an entity.

    Namespace: Unity.Entities
    Syntax
    public struct Entity : IEquatable<Entity>, IComparable<Entity>
    Remarks

    The entity is a fundamental part of the Entity Component System. Everything in your game that has data or an identity of its own is an entity. However, an entity does not 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.

    Entities are managed by the EntityManager class and exist within a World. An Entity struct refers to an entity, but is not a reference. Rather the Entity struct contains an Index used to access entity data and a Version used to check whether the Index is still valid. Note that you generally do not use the Index or Version values directly, but instead pass the Entity struct to the relevant API methods.

    Pass an Entity struct to methods of the EntityManager, the EntityCommandBuffer, or the ComponentSystem in order to add or remove components, to access components, or to destroy the entity.

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

    Burst compatible.

    ToString()

    Provides a debugging string.

    Operators

    Name Description
    Equality(Entity, Entity)

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

    Inequality(Entity, Entity)

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

    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on 04 August 2022
    Terms of use