# ScenePublic

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.script/instanceinterface">Sansar.Script.InstanceInterface</a></span>
</div>

<span id="T:Sansar.Simulation.ScenePublic"></span>

The Public Scene API, a more limited subset of [`ScenePrivate`](/scripting/api/sansar.simulation/sceneprivate).

```csharp
public class ScenePublic : Sansar.Script.InstanceInterface
```

## Members at a glance

| Kind | Members |
|---|---|
| **Properties** | [AgentCount](#agentcount) · [Chat](#chat) · [SceneInfo](#sceneinfo) · [User](#user) |
| **Methods** | [FindAgent](#findagent) · [FindObject](#findobject) · [FindReflective](#findreflective) · [GetAgent](#getagent) · [GetAgents](#getagents) · [GetPortalCreatorName](#getportalcreatorname) · [GetPortalDescription](#getportaldescription) · [GetPortalUri](#getportaluri) · [ToString](#tostring) |

## Properties

### AgentCount

<div class="api-card">
<span id="P:Sansar.Simulation.ScenePublic.AgentCount"></span>

```csharp signature
public uint AgentCount { get; }
```

The number of agents in the Scene.

**Value:** [uint](https://learn.microsoft.com/dotnet/api/system.uint32) — Unsigned integer count of the number of agents in the Scene.

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

This number changes when agents join and part.

</details>

</div>

### Chat

<div class="api-card">
<span id="P:Sansar.Simulation.ScenePublic.Chat"></span>

```csharp signature
public Chat Chat { get; }
```

Gets the Chat interface for this Scene

**Value:** [Chat](/scripting/api/sansar.simulation/chat) — The Chat Api

</div>

### SceneInfo

<div class="api-card">
<span id="P:Sansar.Simulation.ScenePublic.SceneInfo"></span>

```csharp signature
public SceneInfo SceneInfo { get; }
```

Gets the SceneInfo for this Scene

**Value:** [SceneInfo](/scripting/api/sansar.simulation/sceneinfo) — The full SceneInfo Api

</div>

### User

<div class="api-card">
<span id="P:Sansar.Simulation.ScenePublic.User"></span>

```csharp signature
public User User { get; }
```

Gets the User interface for this Scene

**Value:** [User](/scripting/api/sansar.simulation/user) — The User Api

</div>


## Methods

### FindAgent

<div class="api-card" id="findagent-objectid">
<span id="M:Sansar.Simulation.ScenePublic.FindAgent(Sansar.Script.ObjectId)"></span>

```csharp signature
public AgentPublic FindAgent(Sansar.Script.ObjectId objectId)
```

Looks up an AgentInfo associated with the given object id.

| Parameter | Type | Description |
|---|---|---|
| `objectId` | [Sansar.Script.ObjectId](/scripting/api/sansar.script/objectid) | The object to find. |

**Returns:** [AgentPublic](/scripting/api/sansar.simulation/agentpublic) — The AgentInfo, or null if an agent cannot be found with that id.

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

Agents may leave at any time. Attempting to use an Agent or AgentInfo interface for an agent no longer in the scene will throw a NullReferenceException.

</details>

</div>

<div class="api-card" id="findagent-sessionid">
<span id="M:Sansar.Simulation.ScenePublic.FindAgent(Sansar.Script.SessionId)"></span>

```csharp signature
public AgentPublic FindAgent(Sansar.Script.SessionId sessionId)
```

Looks up an AgentInfo associated with the given session id, if they are in the scene.

| Parameter | Type | Description |
|---|---|---|
| `sessionId` | [Sansar.Script.SessionId](/scripting/api/sansar.script/sessionid) | The sessionId of the agent to find. |

**Returns:** [AgentPublic](/scripting/api/sansar.simulation/agentpublic) — The AgentInfo, or null if an agent cannot be found with that id.

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

Agents may leave at any time. Attempting to use an Agent or AgentInfo interface for an agent no longer in the scene will throw a NullReferenceException.

</details>

</div>

<div class="api-card" id="findagent-guid">
<span id="M:Sansar.Simulation.ScenePublic.FindAgent(System.Guid)"></span>

```csharp signature
public AgentPublic FindAgent(Guid personaId)
```

Looks up an AgentInfo associated with the given persona id, if they are in the scene.

| Parameter | Type | Description |
|---|---|---|
| `personaId` | [Guid](https://learn.microsoft.com/dotnet/api/system.guid) | The personaId of the agent to find. |

**Returns:** [AgentPublic](/scripting/api/sansar.simulation/agentpublic) — The agent, or null if an agent cannot be found with that id in the scene.

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

Agents may leave at any time. Attempting to use an Agent or AgentInfo interface for an agent no longer in the scene will throw a NullReferenceException.

</details>

</div>

### FindObject

<div class="api-card">
<span id="M:Sansar.Simulation.ScenePublic.FindObject(Sansar.Script.ObjectId)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 32.0.0</span></div>

```csharp signature
public ObjectPublic FindObject(Sansar.Script.ObjectId objectId)
```

Looks up a Object associated with the given object id.

| Parameter | Type | Description |
|---|---|---|
| `objectId` | [Sansar.Script.ObjectId](/scripting/api/sansar.script/objectid) | The object to find. |

**Returns:** [ObjectPublic](/scripting/api/sansar.simulation/objectpublic) — The ObjectPublic, or null if a Object cannot be found with that id.

</div>

### FindReflective

<div class="api-card">
<span id="M:Sansar.Simulation.ScenePublic.FindReflective``1(System.String)"></span>

```csharp signature
[Sansar.Script.NonReflective]
public IEnumerable<TInterface> FindReflective<TInterface>(
    string name
) where TInterface : class
```

Looks up Reflective objects in the scene that match the interface type by class name.

| Parameter | Type | Description |
|---|---|---|
| `name` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The type name of the object&#39;s class to find. |

**Type parameters:** `TInterface`: The interface type to find.

**Returns:** [IEnumerable&lt;TInterface&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) — An IEnumerable which contains all objects of the given type name that match the given interface.

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

The name given corresponds to the `Type.FullName` of the object. Multiple scripts may define unrelated types of the same name, but only registered objects that match the interface of TInterface will be returned.

</details>

</div>

### GetAgent

<div class="api-card">
<span id="M:Sansar.Simulation.ScenePublic.GetAgent(System.UInt32)"></span>

```csharp signature
public AgentPublic GetAgent(uint index)
```

Get an [`AgentPublic`](/scripting/api/sansar.simulation/agentpublic) for a specific agent in the Scene.

| Parameter | Type | Description |
|---|---|---|
| `index` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | The index of the agent to get. |

**Returns:** [AgentPublic](/scripting/api/sansar.simulation/agentpublic) — Returns null if the index is larger than the number of agents in the Scene.

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

Agents may appear at different indices as they join and part.

</details>

</div>

### GetAgents

<div class="api-card">
<span id="M:Sansar.Simulation.ScenePublic.GetAgents"></span>
<span id="M:Sansar.Simulation.ScenePublic.GetAgents()"></span>

```csharp signature
public IEnumerable<AgentPublic> GetAgents()
```

Returns the current list of Agents in the Scene.

**Returns:** [IEnumerable&lt;AgentPublic&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) — The current list of agents in the Scene

</div>

### GetPortalCreatorName

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

```csharp signature
public string GetPortalCreatorName(Sansar.Script.ObjectId objectId)
```

The name of the user who created the specified portal.

| Parameter | Type | Description |
|---|---|---|
| `objectId` | [Sansar.Script.ObjectId](/scripting/api/sansar.script/objectid) |  |

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

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

User who created the portal.

</details>

</div>

### GetPortalDescription

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

```csharp signature
public string GetPortalDescription(Sansar.Script.ObjectId objectId)
```

Description for the specified portal.

| Parameter | Type | Description |
|---|---|---|
| `objectId` | [Sansar.Script.ObjectId](/scripting/api/sansar.script/objectid) |  |

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

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

The description of the portal.

</details>

</div>

### GetPortalUri

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

```csharp signature
public string GetPortalUri(Sansar.Script.ObjectId objectId)
```

URI destination for the specified portal.

| Parameter | Type | Description |
|---|---|---|
| `objectId` | [Sansar.Script.ObjectId](/scripting/api/sansar.script/objectid) |  |

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

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

The URI of the destination of the portal.

</details>

</div>

### ToString

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

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

A string representation of this object.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — A string representation of this object.

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

The format of this string may change between releases.

</details>

</div>


## Used in examples

- [ObjectScriptExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ObjectScriptExample.cs)
- [ScriptLibrary/LibraryDebugger.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/LibraryDebugger.cs)

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