# ObjectId

Kind: Struct · Namespace: Sansar.Script · Assembly: Sansar.Script.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-struct" data-pagefind-filter="kind:Struct">Struct</span>
<span data-pagefind-filter="namespace:Sansar.Script">Namespace <a href="/scripting/api/sansar.script"><code>Sansar.Script</code></a></span>
</div>

<span id="T:Sansar.Script.ObjectId"></span>

Encapsulates an Object Id.

```csharp
public struct ObjectId
```

## Remarks

An ObjectId can be derived from a [`ComponentId`](/scripting/api/sansar.script/componentid).

## Members at a glance

| Kind | Members |
|---|---|
| **Fields** | [Invalid](#invalid) |
| **Methods** | [Equals](#equals) · [GetHashCode](#gethashcode) · [ToString](#tostring) |
| **Operators** | [op\_Equality](#op_equality) · [op\_Implicit](#op_implicit) · [op\_Inequality](#op_inequality) |

## Fields

### Invalid

<div class="api-card">
<span id="F:Sansar.Script.ObjectId.Invalid"></span>

```csharp signature
public static readonly ObjectId Invalid
```

The invalid id object.

<details class="api-remarks"><summary>Remarks</summary>

This value is used by certain APIs to represent an invalid ObjectId.

</details>

</div>


## Methods

### Equals

<div class="api-card">
<span id="M:Sansar.Script.ObjectId.Equals(System.Object)"></span>

```csharp signature
public override bool Equals(object obj)
```

Value comparison for ObjectId.

| Parameter | Type | Description |
|---|---|---|
| `obj` | [object](https://learn.microsoft.com/dotnet/api/system.object) | The object to compare. |

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the argument is an ObjectId and has the same value.

<details class="api-remarks"><summary>Remarks</summary>

This method overrides [`ValueType.Equals`](https://learn.microsoft.com/dotnet/api/system.valuetype.equals).

</details>

</div>

### GetHashCode

<div class="api-card">
<span id="M:Sansar.Script.ObjectId.GetHashCode"></span>
<span id="M:Sansar.Script.ObjectId.GetHashCode()"></span>

```csharp signature
public override int GetHashCode()
```

Retrieves the hash code for this instance.

**Returns:** [int](https://learn.microsoft.com/dotnet/api/system.int32) — The hash code for this instance.

<details class="api-remarks"><summary>Remarks</summary>

This method overrides [`ValueType.GetHashCode`](https://learn.microsoft.com/dotnet/api/system.valuetype.gethashcode).

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Script.ObjectId.ToString"></span>
<span id="M:Sansar.Script.ObjectId.ToString()"></span>

```csharp signature
public override string ToString()
```

Converts the id to a hexadecimal string representation.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — The hexadecimal string representation.

<details class="api-remarks"><summary>Remarks</summary>

This method overrides [`Object.ToString`](https://learn.microsoft.com/dotnet/api/system.object.tostring).

</details>

</div>


## Operators

### op_Equality

<div class="api-card">
<span id="M:Sansar.Script.ObjectId.op_Equality(Sansar.Script.ObjectId,Sansar.Script.ObjectId)"></span>

```csharp signature
public static bool operator ==(ObjectId a, ObjectId b)
```

ObjectId equality operator.

| Parameter | Type | Description |
|---|---|---|
| `a` | [ObjectId](/scripting/api/sansar.script/objectid) | First ObjectId to compare. |
| `b` | [ObjectId](/scripting/api/sansar.script/objectid) | Second ObjectId to compare. |

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the ObjectIds have the same value.

<details class="api-remarks"><summary>Remarks</summary>

This is a value comparison.

</details>

</div>

### op_Implicit

<div class="api-card">
<span id="M:Sansar.Script.ObjectId.op_Implicit(System.UInt32)~Sansar.Script.ObjectId"></span>

```csharp signature
public static implicit operator ObjectId(uint id)
```

Internal explicit conversion from a uint.

| Parameter | Type | Description |
|---|---|---|
| `id` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | A uint representation of an ObjectId |

**Returns:** [ObjectId](/scripting/api/sansar.script/objectid) — A new ObjectId initialized with the given uint.

<details class="api-remarks"><summary>Remarks</summary>

Internal.

</details>

</div>

### op_Inequality

<div class="api-card">
<span id="M:Sansar.Script.ObjectId.op_Inequality(Sansar.Script.ObjectId,Sansar.Script.ObjectId)"></span>

```csharp signature
public static bool operator !=(ObjectId a, ObjectId b)
```

ObjectId inequality operator.

| Parameter | Type | Description |
|---|---|---|
| `a` | [ObjectId](/scripting/api/sansar.script/objectid) | First ObjectId to compare. |
| `b` | [ObjectId](/scripting/api/sansar.script/objectid) | Second ObjectId to compare. |

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the ObjectIds have a different value.

<details class="api-remarks"><summary>Remarks</summary>

This is a value comparison.

</details>

</div>


## Used in examples

- [FollowThePath.cs](/scripting/examples/follow-the-path)
- [MoverExample1.cs](/scripting/examples/mover-examples)
- [MoverExample3.cs](/scripting/examples/mover-examples)
- [ReflectiveDetectorExample.cs](/scripting/examples/reflective-detector)
- [StatsExample.cs](/scripting/examples/stats-example)
- [AgentGravityExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/AgentGravityExample.cs)
- [AgentScaleExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/AgentScaleExample.cs)
- [BanHammerExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/BanHammerExample.cs)
- [CastRayExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/CastRayExample.cs)
- [EventExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/EventExample.cs)
- [PewPewExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/PewPewExample.cs)
- [ScriptLibrary/LibraryBase.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/LibraryBase.cs)

…and 28 more examples in the snapshot.

<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>