I have a dialog I want to make, that contains some checkboxes and some other random controls. I want to show it to the user when they click on a button (in a custom inspector I have already made) in order to choose what to do.
How would I go about doing this in Unity? I can only find dialog calls that are simple message boxes…
I would strongly recommend using a custom EditorWindow for that purpose. The suggested ScriptableWizard is kinda ugly and gimmicky. It doesn’t provide any substantial benefit, including no modality support.
Create your own window like this, and it will do just fine:
var window = GetWindow<MyWizardWindow>(utility: true, title: "Create New Object", focus: true);
window.ShowUtility();
Your GUI logic then has to be like this:
protected virtual void OnGUI()
{
_Error = null;
EditorGUILayout.PrefixLabel("Name");
_Name = EditorGUILayout.TextField(_Name);
if (!IsValid(this._Name))
_Error = "The name is invalid";
if (!string.IsNullOrEmpty(_Error))
EditorGUILayout.HelpBox(_Error, MessageType.Error);
GUILayout.FlexibleSpace();
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Cancel"))
{
Cancel();
}
EditorGUI.BeginDisabledGroup(!string.IsNullOrEmpty(_Error));
if (GUILayout.Button("Create"))
{
Create();
}
EditorGUI.EndDisabledGroup();
EditorGUILayout.EndHorizontal();
}
Unfortunately (AFAIK) there’s no way to display an editor window as a modal window. The only thing that comes with Unity are the simple dialg boxes you’ve already found (EditorUtility.DisplayDialogComplex).
Well, in a multitasking environment modal windows are evil, Just in some rare cases they would be helpful. Just check if you really need it modal. The user would be pleased when he still can select other things to look up some settings or whatever…