Skip to content

CustomDialog.ShaderGUIDialog

Description

Unity Editor Only

Wrapper to remove the "PropertiesGUI() is being called recursively" warning when calling EditorUtility.DisplayDialog in OnGUI within a ShaderGUI inherited class

Example of using the ShaderGUIDialog

private void OnGUI()
{
    // Get input
    int input = ShaderGUIDialog.DisplayDialogComplex(
        "Title",
        "Message",
        "Ok",
        "Cancel",
        "Alt"
    )

    // Use input
    switch(input) {
        case 0:
            Debug.Log("OK was selected");
            break;
        case 1:
            Debug.Log("CANCEL was selected");
            break;
        case 2:
            Debug.Log("ALT was selected");
            break;
    }
}


DisplayDialog

Declaration

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

Parameters

Parameter Description
title Title of the window
message Message displayed in the dialog
ok Left button underneath the message
cancel Right button underneath the message

Returns

If the ok button was pressed

Description

Displays a modal dialog removing the ShaderGUI specific warning


DisplayDialogComplex

Declaration

public static int DisplayDialogComplex(string title, string message, string ok, string cancel, string alt)

Parameters

Parameter Description
title Title of the window
message Message displayed in the dialog
ok Left button underneath the message
cancel Right button underneath the message
alt Middle button underneath the message

Returns

0, 1, 2 for ok, cancel, alt responses respectively

Description

Displays a modal dialog with three buttons removing the ShaderGUI specific warning