- Home /
GUI.Window vs GUI.ModalWindow
Hello, In my custom editor window this code:
void OnGUI()
{
BeginWindows();
GUI.Window(0, new Rect(0, 0, 500, 500), funcshin, "window");
EndWindows();
}
works correctly while this code:
void OnGUI()
{
BeginWindows();
GUI.ModalWindow(0, new Rect(0, 0, 500, 500), funcshin, "window");
EndWindows();
}
produces nothing at all.
Has anyone come across this or found a solution?
Answer by Bunny83 · Jul 13, 2017 at 01:29 AM
I was starting to think I would have to implement modal windows myself, Then I found GUI.$$anonymous$$odalWIndow, then I went back to thinking I had to do it myself, and now you have shown me two complete solutions to jump off from. Excellent! thank you very much.
After exa$$anonymous$$ing your modal window class and your related comments, it is pretty clear that you really understand this stuff.
If I could bother you one more time... my purpose is a "Save File" popup window in which the user can only enter a string "fileName" and click save or cancel. Do you think I am taking the right approach? Or are the existing Dialogs customizable?
Uhm Unity has wrapper for most open and save dialogs. Just have a look at the EditorUtility class.
DisplayDialog(Complex) - is basically a wrapper for the usual $$anonymous$$essageBox. It only has buttones to choose from. Either one, two or three buttons.
DisplayPopup$$anonymous$$enu - allows you to create a native context menu.
OpenFilePanel - Opens the OS default open file panel
SaveFilePanel - The default save file panel
ps: Of course those are editor functions so they can only be used inside the editor. However i think that was the case here, right?