Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

EndLayoutGroup: BeginLayoutGroup must be called first

Discussion in 'Immediate Mode GUI (IMGUI)' started by DougRichardson, Mar 23, 2018.

  1. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    I have a custom editor that appends a button to the default inspector for a ScriptableObject sub-class. When this button is pressed, I run my build. Everything seems to work, but I get the following error logged to the console after the build completes:

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


    Sometime I get this message too:

    Expected top level layout group missing! Too many GUILayout.EndScrollView/EndVertical/EndHorizontal?
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


    If I comment out the call to Builder.InteractiveBuild, the error message doesn't appear. Builder.InteractiveBuild merges multiple scenes into a single scene file and then calls BuildPipeline.BuildPlayer to build the project using that merged scene.

    There is no GUI code in Builder.InteractiveBuild, although it does call BuildPipeline.BuildPlayer which puts up a progress dialog.

    I also tried making a call to GUILayout.BeginVertical at the beginning of OnInspectorGUI to no avail.

    Any ideas as to what is going on?

    Here is the Editor's OnInspectorGUI:


    public override void OnInspectorGUI()
    {
    DrawDefaultInspector();
    EditorGUILayout.Space();

    if (GUILayout.Button("Build", GUILayout.ExpandWidth(false)))
    {
    Builder.InteractiveBuild((BuildConfiguration)target);
    }
    }
     
    PhannGor and AlwaysBaroque like this.
  2. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    102
    Add GUIUtility.ExitGUI(); after Builder.InteractiveBuild((BuildConfiguration)target);
    It should fix your problem. Enjoy :)
     
  3. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    Was not aware of GUIUtility.ExitGUI(). Exactly what I needed. Thanks.
     
    AcJoker and niki4etoo like this.
  4. jaydeep01

    jaydeep01

    Joined:
    May 22, 2018
    Posts:
    7
    I m getting this same error after process the code after button clicked inside OnInspectorGUI() in unity version 2018.2.5f1 mac os.

    When button click I display progress bar using EditorUtility.DisplayProgressBar() and clear it using EditorUtility.ClearProgressBar();. and also display EditorUtility.DisplayDialog() after it.
    If I comment code of progress bar and display dialog error not occurred any everything works fine.

    In my case GUIUtility.ExitGUI() not working. Any other way to solve this error?
     
  5. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    Can you post the code?
     
  6. jaydeep01

    jaydeep01

    Joined:
    May 22, 2018
    Posts:
    7
    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.         gameScript.ProcessFile(); //It takes 8-10 sec
    9.         EditorUtility.ClearProgressBar();
    10.         EditorUtility.DisplayDialog("Message", "Success.", "Ok");
    11.         GUIUtility.ExitGUI();
    12.     }
    13. }
     
    Last edited: Sep 8, 2018
  7. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    I don't know what the problem is exactly, but my guess is that you're using the API in a way the API designer didn't intend it to be used. For example, there's no point in calling DisplayProgressBar and then immediately calling ClearProgressBar in the same OnInspectorGUI invocation. In immediate mode GUI programming, you'd typically not call a bunch of functions like this in order like you have.

    If you haven't read it already, make sure to read up on Immediate Mode GUI.
     
  8. jaydeep01

    jaydeep01

    Joined:
    May 22, 2018
    Posts:
    7
    @dichardson, Actually I,m processing file by calling the method(see my updated code) in between DisplayProgressBar and ClearProgressBar and it takes 8-10 secs. Here the main problem in mac os is that after selecting the file from OpenFilePanelWithFilters the dialog windows do not disappear from the screen and ProgressBar is displayed behind the dialog windows.

    Is there any way to close the dialog window after selecting the file or another way to handle this situation?
     
    Last edited: Sep 8, 2018
  9. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    Huh. I took your code and put a sleep in to simulate the long processing and it actually worked fine for me on Windows 10 running Unity 2018.2.6f1.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. [CustomEditor(typeof(NewBehaviourScript))]
    5. public class NewBehaviourScriptEditor : Editor {
    6.  
    7.     public override void OnInspectorGUI()
    8.     {
    9.         if (GUILayout.Button("Choose", GUILayout.Width(70), GUILayout.Height(20)))
    10.         {
    11.             string filepath = EditorUtility.OpenFilePanelWithFilters("Choose", "", new string[] { "CSharp", "cs" });
    12.             Debug.Log("filepath is " + filepath);
    13.             EditorUtility.DisplayProgressBar("Processing..", "Shows a progress", 0.2f);
    14.             System.Threading.Thread.Sleep(8000);
    15.             EditorUtility.ClearProgressBar();
    16.             EditorUtility.DisplayDialog("Message", "Success.", "Ok");
    17.             GUIUtility.ExitGUI();
    18.         }
    19.     }
    20. }
    21.  
    NewBehaviourScript was just a default MonoBehavior.
     
  10. jaydeep01

    jaydeep01

    Joined:
    May 22, 2018
    Posts:
    7
    In windows 10 it works fine for me but my error occurs only in mac os.:(
     
  11. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    You should report an issue. Sounds like a bug.
     
  12. jaydeep01

    jaydeep01

    Joined:
    May 22, 2018
    Posts:
    7
    Ok. thanks
     
  13. Darren_Therrien

    Darren_Therrien

    Joined:
    Jun 30, 2016
    Posts:
    33

    Nice. Thanks.
     
  14. GachaJhovenYT

    GachaJhovenYT

    Joined:
    Feb 8, 2020
    Posts:
    2
    hello guys im having a problem with this
     

    Attached Files:

  15. koushiknaik

    koushiknaik

    Joined:
    Apr 10, 2020
    Posts:
    4
    EndLayoutGroup: BeginLayoutGroup must be called first. UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)
    I don't know what to do
     
    wlwl2 likes this.
  16. Remiah17

    Remiah17

    Joined:
    Sep 10, 2019
    Posts:
    1
    i'm getting the same error
    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    everytime i make a new script
     
    krakeninferno, wlwl2 and nco2k like this.
  17. Mrfrostzy

    Mrfrostzy

    Joined:
    Mar 16, 2020
    Posts:
    1
  18. bhoumita

    bhoumita

    Joined:
    Mar 5, 2020
    Posts:
    1
    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  19. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    when disconnecting network connection while in UI a circle showing "loading" is spinning

    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)

    Unity 20201.0b8
     
  20. Thebuilderpro

    Thebuilderpro

    Joined:
    May 13, 2020
    Posts:
    1
    I have this error that keeps coming to me when i try to extract texture from mixamo models in unity this one
    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Please help i've been working so hard on the game it's only the textures left for the player it's the alien soldier model
     
    krakeninferno likes this.
  21. Alcides2040

    Alcides2040

    Joined:
    Jun 19, 2020
    Posts:
    1
    usando UnityEngine;
    usando System.Collections.Generic;


    public class logicapersonaje: MonoBehaviour {
    flotante público velocidadMovimiento = 5.0f;
    flotante público velocidadRotacion = 200.0f;
    animador privado animador;
    flotador público x, y;

    // Se llama al inicio antes de la primera actualización del marco
    Inicio nulo () {
    anim = GetComponent <Animator> ();
    }

    // Actualización se llama una vez por cuadro
    Actualización nula () {
    x = Input.GetAxis ("Horizontal");
    y = Input.GetAxis ("Vertical");

    transform.Rotate (0, x * Time.deltaTime * velocidadRotacion, 0);
    transform.Translate (0, 0, y * Time.deltaTime * velocidadMovimiento);
    }

    }

    POR FAVOR AYUDA: ESE ES EL CODIGO ERROR DE VENTA SCRIP Y ME
    EndLayoutGroup: BeginLayoutGroup debe llamarse primero.UnityEngine.GUIUtility: ProcessEvent (Int32, IntPtr)

    Alguien podria ayudarme Por favor
     
  22. dorusoftware

    dorusoftware

    Joined:
    Jul 5, 2012
    Posts:
    191
    still present in unity 2019.4.1f1 when importing fbx files
     
    krakeninferno and brahim003 like this.
  23. whatyyyyyy

    whatyyyyyy

    Joined:
    May 12, 2020
    Posts:
    1
    You should delete all the library not working.I just fix it recently.
    upload_2020-7-2_16-25-48.png
     
  24. Brayubro

    Brayubro

    Joined:
    Aug 8, 2020
    Posts:
    1
    I Don't Know What To Do
    It says end layer group begin layer group must be called first
    Code:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerMovement : MonoBehaviour {

    public CharacterController2D controller;

    public float runSpeed = 40f;

    float horizontalMove = 0f;
    bool jump = false;
    bool crouch = false;

    // Update is called once per frame
    void Update () {

    horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

    if (Input.GetButtonDown("Jump"))
    {
    jump = true;
    }

    if (Input.GetButtonDown("Crouch"))
    {
    crouch = true;
    } else if (Input.GetButtonUp("Crouch"))
    {
    crouch = false;
    }

    }

    void FixedUpdate ()
    {
    // Move our character
    controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
    jump = false;
    }
    }
     
  25. eldar_unity

    eldar_unity

    Joined:
    Aug 11, 2020
    Posts:
    3
    I'm getting the same error when I try to import a large raw terrain map using the (Import Raw) button in the terrain settings window.

    I'm starting with a fresh new project, so I do the following

    Create new terrain (from dropdown menu)
    go to terrain settings
    Import Raw...
    select file.

    The message appears as soon as I select the file (at the Import Heightmap window appears). I can still edit the settings in the Import Heightmap window, so I set Terrain size at 4096, 1000, 4096, but then nothing happens.

    The heightmap I'm trying to import is rather hefty (900 mb). Am I missing something?
     
    robske likes this.
  26. Jorpro12Ob1

    Jorpro12Ob1

    Joined:
    Aug 13, 2020
    Posts:
    2
    I have the same, this is the code

    using System.Collections;
    using System.Collections.Generic;
    using System.Threading;
    using UnityEngine;

    public class PlayerControl2 : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    if(Input.GetKey("left"))
    {
    gameObject.GetComponent<Rigidbody>().AddForce(new Vector2(-1000f * Time.deltaTime, 0));
    }
    }
    }
     
  27. Jorpro12Ob1

    Jorpro12Ob1

    Joined:
    Aug 13, 2020
    Posts:
    2
    Can anyone help me?
     
  28. idk_idk

    idk_idk

    Joined:
    Aug 9, 2020
    Posts:
    1
    same issue here my code is:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerMovement : MonoBehaviour
    {
    public CharacterController controller;

    public float speed = 12f;
    public float gravity = -9.81f;

    Vector3 velocity;

    void Update()
    {
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

    Vector3 move = transform.right * x + transform.forward * z;

    controller.Move(move * speed * Time.deltaTime);

    velocity y +gravity * Time.deltaTime;

    controller.Move(velocity * Time.deltaTime);
    }
    }
     
  29. brahim003

    brahim003

    Joined:
    Aug 3, 2020
    Posts:
    2
    end layout group: begin layout group must be called first
     
  30. brahim003

    brahim003

    Joined:
    Aug 3, 2020
    Posts:
    2
    after importing fbx file from blender
     
  31. xylerlaws

    xylerlaws

    Joined:
    Sep 22, 2020
    Posts:
    1
    i was trying to make a movement script it was popping up a different error code that i didn't know how to fix so i red a different thing but when i tried swapping stores it shode this up EndLayoutGroup: BeginLayoutGroup must be called first.anyone know how to fix this.
     
  32. JWLewis777

    JWLewis777

    Joined:
    May 17, 2015
    Posts:
    91
    Trying to extract materials from a model FBX that I imported from blender

    I get the same

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

    Error!
     
  33. gtonuimatwek

    gtonuimatwek

    Joined:
    Sep 19, 2020
    Posts:
    4
    HUDController.cs(5,45): error Cs1513: } expected
    this error is eating me up

    here is my code can anyone help

    her is my code




    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;

    public class HUDController : MonoBehaviour {

    using UnityEngine.UI;
    public UI.Text Score;
    public UI.Text BallsLeftText;
    public UI.Text ScoreText;
    public UI.Image Logomarca;
    public UI.Text BallsLeft;

    // Use this for initialization
    void Start () {
    int scWidth = Screen.width;

    if (scWidth > 1200) {
    Score.transform.position = new Vector3 (Score.transform.position.x-0.05f, Score.transform.position.y, Score.transform.position.z);
    Score.fontSize = 80;
    ScoreText.transform.position = new Vector3 (ScoreText.transform.position.x-0.02f, ScoreText.transform.position.y, ScoreText.transform.position.z);
    ScoreText.fontSize = 140;
    BallsLeft.transform.position = new Vector3 (BallsLeft.transform.position.x-0.05f, BallsLeft.transform.position.y, BallsLeft.transform.position.z);
    BallsLeft.fontSize = 80;
    BallsLeftText.transform.position = new Vector3 (BallsLeftText.transform.position.x-0.02f, BallsLeftText.transform.position.y, BallsLeftText.transform.position.z);
    BallsLeftText.fontSize = 140;
    }

    //(Screen.height / defaultScreenSize) * defaultFontSize

    // GUI.Label (new Rect (scWidth/2.6f, scHeigth/7, scWidth/4, scHeigth/4), msgTexture);
    }

    // Update is called once per frame
    void Update () {

    }
     
    krakeninferno likes this.
  34. Blake_Fitzgerald

    Blake_Fitzgerald

    Joined:
    Jul 11, 2019
    Posts:
    2
    Hey everyone make sure you didn't click the button next to the play game button on unity 2020 that says local/global - i had this problem and same error in my game and could not play test what im making because i accidentally pressed the button at some point apparently.
     
  35. SonicTheHedgiehog

    SonicTheHedgiehog

    Joined:
    Nov 15, 2020
    Posts:
    12
    you haven't placed the } of the class. also if your update is empty just remove it.

    just place an } after update method.
     
  36. yonatanstern2004

    yonatanstern2004

    Joined:
    Feb 24, 2021
    Posts:
    2
    Hey so im really new to coding, and I've been trying to make a game for fun, but I get that error and I have no idea what you said. I've tried to look everywhere but I cant find any other people that have simplified it in an easier way. Would you please be able to do that?
     
  37. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,729
    Which error? Please include the top few lines of the error from the Unity Console.
     
  38. yonatanstern2004

    yonatanstern2004

    Joined:
    Feb 24, 2021
    Posts:
    2
    this is the error:
    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  39. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,729
    Does this occur in editor code you wrote? If so provide a code snippet and place it in the message using the Code icon in the message toolbar (which makes it easier for everyone to read).
    If it just occurs sometime when using the Unity editor it is more likely an asset you downloaded from the Asset Store OR a bug in the Unity editor (which there are several that generate this error).
     
  40. AnimationSB

    AnimationSB

    Joined:
    Mar 8, 2021
    Posts:
    21
    I am experiencing the same problem
    upload_2021-4-8_13-50-2.png

    when I double click here to check where its coming from, VS2019 loads, but then nothing happens. even if i double click the error again, nothing loads up on VS2019

    I saw some fixes shared here, on some code, but I can't load any code to try them out.

    upload_2021-4-8_13-50-47.png
     
unityunity