# MeshComponent

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>
<span class="api-badge api-since">Added in 34.0.0</span>
</div>

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

The MeshComponent handles interactions with static meshes.

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

## Members at a glance

| Kind | Members |
|---|---|
| **Fields** | [ComponentType](#componenttype) |
| **Properties** | [ComponentId](#componentid) · [IsScriptable](#isscriptable) · [Name](#name) |
| **Methods** | [GetIsVisible](#getisvisible) · [GetRenderMaterial](#getrendermaterial) · [GetRenderMaterials](#getrendermaterials) · [SetIsVisible](#setisvisible) · [ToString](#tostring) |

## Fields

### ComponentType

<div class="api-card">
<span id="F:Sansar.Simulation.MeshComponent.ComponentType"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public static readonly ComponentType ComponentType
```

The [`MeshComponent.ComponentType`](/scripting/api/sansar.simulation/meshcomponent#componenttype) of this component

</div>


## Properties

### ComponentId

<div class="api-card">
<span id="P:Sansar.Simulation.MeshComponent.ComponentId"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public Sansar.Script.ComponentId ComponentId { get; }
```

Retrieves the component id for this MeshComponent.

**Value:** [Sansar.Script.ComponentId](/scripting/api/sansar.script/componentid) — The id.

</div>

### IsScriptable

<div class="api-card">
<span id="P:Sansar.Simulation.MeshComponent.IsScriptable"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public bool IsScriptable { get; }
```

The scriptable flag for this MeshComponent.

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — Whether or not this mesh can have properties changed by script.

</div>

### Name

<div class="api-card">
<span id="P:Sansar.Simulation.MeshComponent.Name"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public string Name { get; }
```

This MeshComponent name, as specified in the editor.

</div>


## Methods

### GetIsVisible

<div class="api-card">
<span id="M:Sansar.Simulation.MeshComponent.GetIsVisible"></span>
<span id="M:Sansar.Simulation.MeshComponent.GetIsVisible()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public bool GetIsVisible()
```

Retrieves the visibility state of this MeshComponent.

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — The visibility state.

</div>

### GetRenderMaterial

<div class="api-card">
<span id="M:Sansar.Simulation.MeshComponent.GetRenderMaterial(System.String)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 37.0.0</span></div>

```csharp signature
public RenderMaterial GetRenderMaterial(string renderMaterialName)
```

Gets a specific RenderMaterial or null if there is no RenderMaterial of that name.

| Parameter | Type | Description |
|---|---|---|
| `renderMaterialName` | [string](https://learn.microsoft.com/dotnet/api/system.string) | renderMaterialName |

**Returns:** [RenderMaterial](/scripting/api/sansar.simulation/rendermaterial)

</div>

### GetRenderMaterials

<div class="api-card">
<span id="M:Sansar.Simulation.MeshComponent.GetRenderMaterials"></span>
<span id="M:Sansar.Simulation.MeshComponent.GetRenderMaterials()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 37.0.0</span></div>

```csharp signature
public IEnumerable<RenderMaterial> GetRenderMaterials()
```

Gets the array of all RenderMaterials for this MeshComponent.

**Returns:** [IEnumerable&lt;RenderMaterial&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)

</div>

### SetIsVisible

<div class="api-card" id="setisvisible-boolean">
<span id="M:Sansar.Simulation.MeshComponent.SetIsVisible(System.Boolean)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public void SetIsVisible(bool isVisible)
```

Sets the visibility state of this MeshComponent.

| Parameter | Type | Description |
|---|---|---|
| `isVisible` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The visibility state to set. |

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

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setisvisible-sessionid-boolean">
<span id="M:Sansar.Simulation.MeshComponent.SetIsVisible(Sansar.Script.SessionId,System.Boolean)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public void SetIsVisible(
    Sansar.Script.SessionId sessionId,
    bool isVisible
)
```

Sets the visibility state of this MeshComponent.

| Parameter | Type | Description |
|---|---|---|
| `sessionId` | [Sansar.Script.SessionId](/scripting/api/sansar.script/sessionid) | The sessionId of the user to change static mesh visibility for. |
| `isVisible` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The visibility state to set. |

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

It will only change static mesh visibility for a single user and will not persist across client restarts, server restarts, or leaving the scene (even for changing avatars).

</details>

</div>

<div class="api-card" id="setisvisible-agentprivate-boolean">
<span id="M:Sansar.Simulation.MeshComponent.SetIsVisible(Sansar.Simulation.AgentPrivate,System.Boolean)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public void SetIsVisible(AgentPrivate agent, bool isVisible)
```

Sets the visibility state of this MeshComponent.

| Parameter | Type | Description |
|---|---|---|
| `agent` | [AgentPrivate](/scripting/api/sansar.simulation/agentprivate) | The agent to change static mesh visibility for. |
| `isVisible` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The visibility state to set. |

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

It will only change static mesh visibility for a single user and will not persist across client restarts, server restarts, or leaving the scene (even for changing avatars).

</details>

</div>

<div class="api-card" id="setisvisible-boolean-action">
<span id="M:Sansar.Simulation.MeshComponent.SetIsVisible(System.Boolean,System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public void SetIsVisible(
    bool isVisible,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the visibility state of this MeshComponent.

| Parameter | Type | Description |
|---|---|---|
| `isVisible` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The visibility state to set. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

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

This asynchronous method queues the write then returns. To block until the write has occurred, pass this method to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor) while in a coroutine.

</details>

</div>

<div class="api-card" id="setisvisible-sessionid-boolean-action">
<span id="M:Sansar.Simulation.MeshComponent.SetIsVisible(Sansar.Script.SessionId,System.Boolean,System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public void SetIsVisible(
    Sansar.Script.SessionId sessionId,
    bool isVisible,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the visibility state of this MeshComponent.

| Parameter | Type | Description |
|---|---|---|
| `sessionId` | [Sansar.Script.SessionId](/scripting/api/sansar.script/sessionid) | The sessionId of the user to change static mesh visibility for. |
| `isVisible` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The visibility state to set. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

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

It will only change static mesh visibility for a single user and will not persist across client restarts, server restarts, or leaving the scene (even for changing avatars).

</details>

</div>

<div class="api-card" id="setisvisible-agentprivate-boolean-action">
<span id="M:Sansar.Simulation.MeshComponent.SetIsVisible(Sansar.Simulation.AgentPrivate,System.Boolean,System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```csharp signature
public void SetIsVisible(
    AgentPrivate agent,
    bool isVisible,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the visibility state of this MeshComponent.

| Parameter | Type | Description |
|---|---|---|
| `agent` | [AgentPrivate](/scripting/api/sansar.simulation/agentprivate) | The agent to change static mesh visibility for. |
| `isVisible` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The visibility state to set. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

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

It will only change static mesh visibility for a single user and will not persist across client restarts, server restarts, or leaving the scene (even for changing avatars).

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Simulation.MeshComponent.ToString"></span>
<span id="M:Sansar.Simulation.MeshComponent.ToString()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 34.0.0</span></div>

```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

- [MeshVisibilityExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/MeshVisibilityExample.cs)
- [ScriptLibrary/Quest/QuestObjectInteraction.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestObjectInteraction.cs)
- [ScriptLibrary/Quest/QuestVisibility.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestVisibility.cs)
- [ScriptLibrary/Scene/Visibility.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Visibility.cs)

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