Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    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. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    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. }