I need an equivalent to EditorUtility.DisplayDialog
except that I want to have customizable values in the dialogue (content of a ScriptableObject), like an EditorWindow, or a ScriptableWizard have, but want to keep the ability to halt the editor code execution and resume it depending on the button choice.
This is for checking the configuration of a ScriptableObject on the fly, while the user chose a build menu.
Is this possible?
I found a way, this is how I did it:
public class CustomScriptableWizard : ScriptableWizard
{
CustomScriptableObject customScriptableObject;
Editor customScriptableObjectEditor;
[NonSerialized] public Action SuccessAction;
private void OnEnable()
{
customScriptableObject= Resources.Load<CustomScriptableObject>(<ResourcesPathToCustomScriptableObject>);
}
private void OnGUI()
{
if (!customScriptableObjectEditor)
Editor.CreateCachedEditor(customScriptableObject, null, ref customScriptableObjectEditor);
customScriptableObjectEditor.OnInspectorGUI();
if (GUILayout.Button(createButtonName))
SuccessAction?.Invoke();
}
}
calling it like this:
CustomScriptableWizard debugSettingsBuildWindow = ScriptableWizard.DisplayWizard<CustomScriptableWizard>(<Header>, <createButtonName>);
debugSettingsBuildWindow.SuccessAction = () => Debug.Log("Works");