# ModalDialog

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.ModalDialog"></span>

Manages a modal dialog which can be presented to the user.

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

## Remarks

Set the message and the button text.

## Members at a glance

| Kind | Members |
|---|---|
| **Properties** | [Message](#message) · [Response](#response) |
| **Methods** | [Cancel](#cancel) · [Show](#show) · [ToString](#tostring) |

## Properties

### Message

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

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

The message displayed on the dialog.

**Value:** [string](https://learn.microsoft.com/dotnet/api/system.string) — The string displayed on the dialog.

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

This is set by the [`ModalDialog.Show`](/scripting/api/sansar.simulation/modaldialog#show-string-string-string-operationcomplete) method upon creation.

</details>

</div>

### Response

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

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

The response from the last [`ModalDialog.Show`](/scripting/api/sansar.simulation/modaldialog#show-string-string-string-operationcomplete) call.

**Value:** [string](https://learn.microsoft.com/dotnet/api/system.string) — String response from the last show call.

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

This value will be valid after the event occurs.

</details>

</div>


## Methods

### Cancel

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

```csharp signature
public void Cancel()
```

Cancels any existing dialog.

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

Does not generate an event.

</details>

</div>

### Show

<div class="api-card" id="show-string-string-string">
<span id="M:Sansar.Simulation.ModalDialog.Show(System.String,System.String,System.String)"></span>

```csharp signature
public void Show(
    string message,
    string leftButton,
    string rightButton
)
```

Shows a Modal Dialog on the screen.

| Parameter | Type | Description |
|---|---|---|
| `message` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the dialog. |
| `leftButton` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the left button. |
| `rightButton` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the right button. |

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

Call this with [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-action-t-t-t) in a coroutine to block until the event is generated.

</details>

</div>

<div class="api-card" id="show-string-string-string-operationcomplete">
<span id="M:Sansar.Simulation.ModalDialog.Show(System.String,System.String,System.String,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Show(
    string message,
    string leftButton,
    string rightButton,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Shows a Modal Dialog on the screen.

| Parameter | Type | Description |
|---|---|---|
| `message` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the dialog. |
| `leftButton` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the left button. |
| `rightButton` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the right button. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — The internal event id for the completion event.

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

Call this with [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-action-t-t-t) in a coroutine to block until the event is generated.

</details>

</div>

<div class="api-card" id="show-string-string-string-action">
<span id="M:Sansar.Simulation.ModalDialog.Show(System.String,System.String,System.String,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void Show(
    string message,
    string leftButton,
    string rightButton,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Shows a Modal Dialog on the screen.

| Parameter | Type | Description |
|---|---|---|
| `message` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the dialog. |
| `leftButton` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the left button. |
| `rightButton` | [string](https://learn.microsoft.com/dotnet/api/system.string) | Text of the right button. |
| `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>

Call this with [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-action-t-t-t) in a coroutine to block until the event is generated.

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Simulation.ModalDialog.ToString"></span>
<span id="M:Sansar.Simulation.ModalDialog.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

- [MoverExample1.cs](/scripting/examples/mover-examples)
- [StatsExample.cs](/scripting/examples/stats-example)
- [VisitorTrackerExample.cs](/scripting/examples/visitor-tracker)
- [BanHammerExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/BanHammerExample.cs)
- [ScriptLibrary/Scene/Prompt.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Prompt.cs)

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