Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


EntityId

A unique identifier for a Unity object.
Read time 2 minutesLast updated 4 days ago

Definition

public struct EntityId : IEquatable<EntityId>, IComparable<EntityId>, IFormattable

Remarks

The internal representation of
EntityId
is an implementation detail and might change between versions. To ensure compatibility, avoid the following patterns:
  • Casting
    EntityId
    to or from an integer type.
  • Assuming any particular bit layout or sign conventions.
  • Using
    Object.GetHashCode
    as a substitute for, or to derive, an
    EntityId
    .
  • Serializing
    EntityId
    with
    ToString
    and deserializing with integer parsing.
  • Sorting
    EntityId
    values to determine creation order.
  • Manipulating individual bits of the
    EntityId
    value.
To work with
EntityId
values, use the provided API methods, such as EntityId.ToULong, EntityId.FromULong, EntityId.IsValid, EntityId.Equals, and EntityId.GetHashCode.
Note: Code that previously used
InstanceID
as an integer should be updated to use the
EntityId
API methods instead.

Static Properties

Property

Description

NoneGets an EntityId that represents no valid Object or Entity. Use this to indicate an invalid or unassigned identifier.

Methods

Method

Description

CompareToCompares this EntityId to another EntityId.
EqualsDetermines whether the specified object is equal to this EntityId.
GetHashCodeReturns a hash code for this EntityId.
IsValidDetermines whether this EntityId represents a valid entity.
ToStringReturns a string representation of this EntityId.

Static Methods

Method

Description

FromULongCreates an EntityId from raw ulong data. This should have come from another valid EntityId. (Use at your own risk. And bit arrangement might change.)
ToULongGets the raw data of the EntityId. (Use at your own risk. And bit arrangement might change.)

Operators

Operator

Description

operator ==Determines whether two EntityId instances are equal.
operator >Determines whether the first EntityId is greater than the second.
operator >=Determines whether the first EntityId is greater than or equal to the second.
operator !=Determines whether two EntityId instances are not equal.
operator <Determines whether the first EntityId is less than the second.
operator <=Determines whether the first EntityId is less than or equal to the second.