Search Unity

OpenFilePanelWithFilters does not close and due console error

Discussion in 'Immediate Mode GUI (IMGUI)' started by jaydeep01, Sep 10, 2018.

  1. jaydeep01


    May 22, 2018
    Inside my custom editor GUI button use to open file dialog to select file and process it, during the time of process I have displayed Progress bar and clear it after completion of the process and at last, I have displayed the success message in the dialog and following error popup in the console.

    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

    Open file dialog should be closed after selecting the file but after selecting the file from OpenFilePanelWithFilters the open file dialog do not disappear from the screen and ProgressBar is displayed behind the open file dialog.

    Is there any way to close the dialog or to handle this error I'm missing something ??

    Note: This code is working fine in Windows and error occurs only in mac os. (using Unity Version 2018.2.7f1)

    If I comment code of progress bar and display dialog error not occurred any everything works fine. But I have to use this code in my scenario.

    Code (CSharp):
    1. public override void OnInspectorGUI()
    2. {
    3.     GameScript gameScript = (GameScript)target;
    4.     if (GUILayout.Button("Choose", GUILayout.Width(70), GUILayout.Height(20)))
    5.     {
    6.         string filepath = EditorUtility.OpenFilePanelWithFilters("Choose", "", filters);
    7.         EditorUtility.DisplayProgressBar("Processing..", "Shows a progress", 0.2f);
    8.         Thread.Sleep(8000);
    9.         EditorUtility.ClearProgressBar();
    10.         EditorUtility.DisplayDialog("Message", "Success.", "Ok");
    11.         GUIUtility.ExitGUI();
    12.     }
    13. }