# DisplayDialog

> This method displays a modal dialog.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## DisplayDialog(string, string, string, string)

This method displays a modal dialog.

```csharp
public static bool DisplayDialog(string title, string message, string ok, string cancel)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The title of the dialog box. If left null, defaults to "Unity".**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text of the message.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label displayed on the OK dialog button.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label displayed on the Cancel dialog button.

### Returns

| Type                                                          | Description                                                                 |
| ------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns `true` if the user clicks the OK button. Returns `false` otherwise. |

### Remarks

Use it for displaying message boxes in the Editor. If `message` is null or whitespace, an `ArgumentNullException` is thrown. If `messageText` is longer than 512 characters, it is truncated and the full message is logged to the console in markdown format.

ok and `cancel` are labels to be displayed on the dialog buttons. If `cancel` is empty (the default), then only one button is displayed. DisplayDialog returns `true` if `ok` button is pressed. If any button's text is longer than 64 characters, an `ArgumentException` is thrown.

For dialog boxes that might be shown repeatedly, consider using an overload of this method that takes a [DialogOptOutDecisionType](/engine/6000.7/script-reference/unityeditor/dialogoptoutdecisiontype.md) as described in the below the code example.

![DisplayDialog1 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialog1.png)

*Dialog box that has one button.*

![DisplayDialog2 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialog2.png)

*Dialog box that has two buttons.*

**Note:** `EditorUtility.DisplayDialog` and `EditorUtility.DisplayDialogComplex` are kept for backwards compatibilty. For new code, it is strongly recommended to use one of the new [EditorDialog](/engine/6000.7/script-reference/unityeditor/editordialog.md) methods.

Additional Resources:

* [EditorDialog.DisplayAlertDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialog.md)
* [EditorDialog.DisplayAlertDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialogwithoptout.md)
* [EditorDialog.DisplayDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialog.md)
* [EditorDialog.DisplayDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialogwithoptout.md)
* [EditorDialog.DisplayComplexDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialog.md)
* [EditorDialog.DisplayComplexDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialogwithoptout.md).

## DisplayDialog(string, string, string)

This method displays a modal dialog.

```csharp
public static bool DisplayDialog(string title, string message, string ok)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The title of the dialog box. If left null, defaults to "Unity".**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text of the message.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label displayed on the OK dialog button.

### Returns

| Type                                                          | Description                                                                 |
| ------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns `true` if the user clicks the OK button. Returns `false` otherwise. |

### Remarks

Use it for displaying message boxes in the Editor. If `message` is null or whitespace, an `ArgumentNullException` is thrown. If `messageText` is longer than 512 characters, it is truncated and the full message is logged to the console in markdown format.

ok and `cancel` are labels to be displayed on the dialog buttons. If `cancel` is empty (the default), then only one button is displayed. DisplayDialog returns `true` if `ok` button is pressed. If any button's text is longer than 64 characters, an `ArgumentException` is thrown.

For dialog boxes that might be shown repeatedly, consider using an overload of this method that takes a [DialogOptOutDecisionType](/engine/6000.7/script-reference/unityeditor/dialogoptoutdecisiontype.md) as described in the below the code example.

![DisplayDialog1 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialog1.png)

*Dialog box that has one button.*

![DisplayDialog2 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialog2.png)

*Dialog box that has two buttons.*

**Note:** `EditorUtility.DisplayDialog` and `EditorUtility.DisplayDialogComplex` are kept for backwards compatibilty. For new code, it is strongly recommended to use one of the new [EditorDialog](/engine/6000.7/script-reference/unityeditor/editordialog.md) methods.

Additional Resources:

* [EditorDialog.DisplayAlertDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialog.md)
* [EditorDialog.DisplayAlertDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialogwithoptout.md)
* [EditorDialog.DisplayDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialog.md)
* [EditorDialog.DisplayDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialogwithoptout.md)
* [EditorDialog.DisplayComplexDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialog.md)
* [EditorDialog.DisplayComplexDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialogwithoptout.md).

## DisplayDialog(string, string, string, DialogOptOutDecisionType, string)

This method displays a modal dialog that lets the user opt-out of being shown the current dialog box again.

```csharp
public static bool DisplayDialog(string title, string message, string ok, DialogOptOutDecisionType dialogOptOutDecisionType, string dialogOptOutDecisionStorageKey)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The title of the dialog box. If left null, defaults to "Unity".**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text of the message.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label displayed on the OK dialog button.**** (\[DialogOptOutDecisionType]\(/engine/6000.7/script-reference/unityeditor/dialogoptoutdecisiontype)): Where the result is stored if the user opts out of the dialog by checking the box.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The key to use for storing the opt-out decision.

### Returns

| Type                                                          | Description                                                                                                                                           |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true if the user clicks the `ok` button, or previously opted out. Returns `false` if the user cancels or closes the dialog without making a decision. |

### Remarks

Use this method to display dialog boxes in the Editor that might be shown repeatedly. Choose which DialogOptOutDecisionType to use based on how often you think users encounter this message and how often you want to remind them of it.

If the user opts-out of seeing the dialog box associated with the provided `dialogOptOutDecisionStorageKey`, Unity doesn't show the dialog box and this method immediately returns `true`.

ok and `cancel` are labels to be displayed on the dialog buttons. If `cancel` is empty (the default), then only one button is displayed. DisplayDialog returns `true` if `ok` button is pressed. If any button's text is longer than 64 characters, an `ArgumentException` is thrown.

If `dialogOptOutDecisionStorageKey` is not a valid XML tag, or more than 127 characters long, an ArgumentException is thrown. Care should be taken to ensure that the key is unique to the dialog box being displayed to prevent conflicts. The decision is only stored if the user checks the opt-out checkbox and clicks the Yes button. The user can reset the option in user preferences.

![DisplayDialogO1 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialogO1.png)

*Dialog box that can opt out for this session.*

![DisplayDialogO2 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialogO2.png)

*Dialog box that can be opted out more permanently.*

**Note:** `EditorUtility.DisplayDialog` and `EditorUtility.DisplayDialogComplex` are kept for backwards compatibilty. For new code, it is strongly recommended to use one of the new [EditorDialog](/engine/6000.7/script-reference/unityeditor/editordialog.md) methods.

Additional Resources:

* [EditorDialog.DisplayAlertDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialog.md)
* [EditorDialog.DisplayAlertDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialogwithoptout.md)
* [EditorDialog.DisplayDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialog.md)
* [EditorDialog.DisplayDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialogwithoptout.md)
* [EditorDialog.DisplayComplexDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialog.md)
* [EditorDialog.DisplayComplexDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialogwithoptout.md).

## DisplayDialog(string, string, string, string, DialogOptOutDecisionType, string)

This method displays a modal dialog that lets the user opt-out of being shown the current dialog box again.

```csharp
public static bool DisplayDialog(string title, string message, string ok, string cancel, DialogOptOutDecisionType dialogOptOutDecisionType, string dialogOptOutDecisionStorageKey)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The title of the dialog box. If left null, defaults to "Unity".**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text of the message.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label displayed on the OK dialog button.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label displayed on the Cancel dialog button.**** (\[DialogOptOutDecisionType]\(/engine/6000.7/script-reference/unityeditor/dialogoptoutdecisiontype)): Where the result is stored if the user opts out of the dialog by checking the box.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The key to use for storing the opt-out decision.

### Returns

| Type                                                          | Description                                                                                                                                           |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true if the user clicks the `ok` button, or previously opted out. Returns `false` if the user cancels or closes the dialog without making a decision. |

### Remarks

Use this method to display dialog boxes in the Editor that might be shown repeatedly. Choose which DialogOptOutDecisionType to use based on how often you think users encounter this message and how often you want to remind them of it.

If the user opts-out of seeing the dialog box associated with the provided `dialogOptOutDecisionStorageKey`, Unity doesn't show the dialog box and this method immediately returns `true`.

ok and `cancel` are labels to be displayed on the dialog buttons. If `cancel` is empty (the default), then only one button is displayed. DisplayDialog returns `true` if `ok` button is pressed. If any button's text is longer than 64 characters, an `ArgumentException` is thrown.

If `dialogOptOutDecisionStorageKey` is not a valid XML tag, or more than 127 characters long, an ArgumentException is thrown. Care should be taken to ensure that the key is unique to the dialog box being displayed to prevent conflicts. The decision is only stored if the user checks the opt-out checkbox and clicks the Yes button. The user can reset the option in user preferences.

![DisplayDialogO1 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialogO1.png)

*Dialog box that can opt out for this session.*

![DisplayDialogO2 (DisplayDialog)](/api/media?file=/engine/6000.7/media/images/DisplayDialogO2.png)

*Dialog box that can be opted out more permanently.*

**Note:** `EditorUtility.DisplayDialog` and `EditorUtility.DisplayDialogComplex` are kept for backwards compatibilty. For new code, it is strongly recommended to use one of the new [EditorDialog](/engine/6000.7/script-reference/unityeditor/editordialog.md) methods.

Additional Resources:

* [EditorDialog.DisplayAlertDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialog.md)
* [EditorDialog.DisplayAlertDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displayalertdialogwithoptout.md)
* [EditorDialog.DisplayDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialog.md)
* [EditorDialog.DisplayDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaydecisiondialogwithoptout.md)
* [EditorDialog.DisplayComplexDecisionDialog](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialog.md)
* [EditorDialog.DisplayComplexDecisionDialogWithOptOut](/engine/6000.7/script-reference/unityeditor/editordialog/displaycomplexdecisiondialogwithoptout.md).
