EntityId
A unique identifier for a Unity object.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Struct
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Implements: IEquatable<EntityId>, IComparable<EntityId>, IFormattable
public struct EntityId : IEquatable<EntityId>, IComparable<EntityId>, IFormattable
Remarks
The internal representation of is an implementation detail and might change between versions. To ensure compatibility, avoid the following patterns:
EntityId- Casting to or from an integer type.
EntityId - Assuming any particular bit layout or sign conventions.
- Using as a substitute for, or to derive, an
Object.GetHashCode.EntityId - Serializing with
EntityIdand deserializing with integer parsing.ToString - Sorting values to determine creation order.
EntityId - Manipulating individual bits of the value.
EntityId
To work with values, use the provided API methods, such as EntityId.ToULong, EntityId.FromULong, EntityId.IsValid, EntityId.Equals, and EntityId.GetHashCode.
EntityIdNote: Code that previously used as an integer should be updated to use the API methods instead.
InstanceIDEntityIdStatic Properties
Property | Description |
|---|---|
| None | Gets an EntityId that represents no valid Object or Entity. Use this to indicate an invalid or unassigned identifier. |
Methods
Method | Description |
|---|---|
| CompareTo | Compares this EntityId to another EntityId. |
| Equals | Determines whether the specified object is equal to this EntityId. |
| GetHashCode | Returns a hash code for this EntityId. |
| IsValid | Determines whether this EntityId represents a valid entity. |
| ToString | Returns a string representation of this EntityId. |
Static Methods
Method | Description |
|---|---|
| FromULong | Creates an EntityId from raw ulong data. This should have come from another valid EntityId. (Use at your own risk. And bit arrangement might change.) |
| ToULong | Gets 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. |