Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

OpenFilePanelWithFilters does not close and due console error

Discussion in 'Extensions & OnGUI' started by jaydeep01, Sep 10, 2018.

  1. jaydeep01

    jaydeep01

    Joined:
    May 22, 2018
    Posts:
    7
    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. }