# EntityGuid

> This component is attached to converted Entities and is guaranteed to be unique within a World. It can be used to map back to the authoring GameObject from which it was converted. Note that an EntityGuid does not have enough information to be persistent across sessions.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule
* **Implements:** [IComponentData](/engine/7000.0/script-reference/unity/entities/icomponentdata.md), [IQueryTypeParameter](/engine/7000.0/script-reference/unity/entities/iquerytypeparameter.md), [IEquatable\<EntityGuid>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IComparable\<EntityGuid>](https://learn.microsoft.com/dotnet/api/system.icomparable-1)

```csharp
public struct EntityGuid : IComponentData, IQueryTypeParameter, IEquatable<EntityGuid>, IComparable<EntityGuid>
```

## Static Fields

| Value                                                                     | Description                                         |
| ------------------------------------------------------------------------- | --------------------------------------------------- |
| [Null](/engine/7000.0/script-reference/unity/entities/entityguid/null.md) | Static value that represents an invalid EntityGuid. |

## Constructors

| Constructor                                                                                                                                            | Description                                                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
| [EntityGuid(UnityEngine.EntityId,UnityEngine.EntityId,System.UInt32,System.UInt32)](/engine/7000.0/script-reference/unity/entities/entityguid/ctor.md) | Initializes a new instance of the [EntityGuid](/engine/7000.0/script-reference/unity/entities/entityguid.md). |

## Properties

| Property                                                                                                      | Description                                                                                                   |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| [NamespaceAndSerial](/engine/7000.0/script-reference/unity/entities/entityguid/namespaceandserial.md)         | A unique number combining the FullNamespaceId and Serial into a ulong.                                        |
| [OriginatingEntityId](/engine/7000.0/script-reference/unity/entities/entityguid/originatingentityid.md)       | Session-unique ID for originating object (typically the authoring GameObject's EntityId).                     |
| [OriginatingSubEntityId](/engine/7000.0/script-reference/unity/entities/entityguid/originatingsubentityid.md) | Secondary session-unique ID for the originating object. This is typically the authoring Component's EntityId. |
| [Serial](/engine/7000.0/script-reference/unity/entities/entityguid/serial.md)                                 | A unique number used to differentiate Entities associated with the same originating object and namespace.     |

## Methods

| Method                                                                                  | Description                                                           |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| [CompareTo](/engine/7000.0/script-reference/unity/entities/entityguid/compareto.md)     | Compares an EntityGuid against a given one to find their sort order.  |
| [Equals](/engine/7000.0/script-reference/unity/entities/entityguid/equals.md)           | Checks if two objects are EntityGuid instances and if they are equal. |
| [GetHashCode](/engine/7000.0/script-reference/unity/entities/entityguid/gethashcode.md) | Computes a hashcode to support hash-based collections.                |
| [ToString](/engine/7000.0/script-reference/unity/entities/entityguid/tostring.md)       | Converts this EntityGuid to a standard C# string representation.      |

## Operators

| Operator                                                                                  | Description                                      |
| ----------------------------------------------------------------------------------------- | ------------------------------------------------ |
| [operator ==](/engine/7000.0/script-reference/unity/entities/entityguid/op-equality.md)   | Checks if two EntityGuid instances are equal.    |
| [operator !=](/engine/7000.0/script-reference/unity/entities/entityguid/op-inequality.md) | Checks if two EntityGuid instances aren't equal. |
