Search Unity

EndLayoutGroup: BeginLayoutGroup must be called first.

Discussion in 'UI Toolkit' started by aflynn810, Mar 2, 2020.

  1. aflynn810

    aflynn810

    Joined:
    Feb 26, 2020
    Posts:
    3
    Hey guys im super new to unity and ive been trying to make a health bar system for the last few days with no success. I think ive finally narrowed down the problem to a compiler error. However i have no idea why and my googling is only coming up with results for other issues that im not yet learned enough to translate to my problem. The real issue im having is my "public Slider slider;" isnt creating a variable slot in my inspector.

    this code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UIElements;
    5.  
    6. public class HealthBar : MonoBehaviour
    7. {
    8.    
    9.     public Slider slider;
    10.  
    11.     public void setMaxHealth(int health)
    12.     {
    13.         slider.value = health;
    14.     }
    15.  
    16. }
    Is throwing this error:
    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr) (at /home/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:187).

    Does anyone have any ideas what the problem is? Im sure its something super simple that im missing.
     
  2. alexandred_unity

    alexandred_unity

    Unity Technologies

    Joined:
    Dec 12, 2018
    Posts:
    43
    Slider (any visual element type) type is not supported in the inspector. What version do you use? I tried your script but did not get any exception.
     
  3. aflynn810

    aflynn810

    Joined:
    Feb 26, 2020
    Posts:
    3
    2019.3. so I did more digging and troubleshooting. I found on a brand new project it doesn't throw the error and it also creates the variable slot in the inspector. The code works on a brand new project using UnityEngine.UI instead of .UIElements. On the original project where the code doesn't work, unityengine.ui is not recognizable or valid. I just initially assumed2019.3 replaced it with .elements. But In the new project unityengine.ui is somehow recognizable. So at some point my dependencies(?) Or where ever unityengine.ui is saved got messed with and removed? I however did not mess with anything like that as far as I'm aware. I did see other people were having that issue if they downloaded and imported stuff from the asset store sometimes, and I had about 4-5 asset packages imported.

    So idk. At this point I just restarted my project as I wasn't super far into it, only just started creating a health bar. Does any of that sounds familiar to you? Any advice if it happens again? Thanks for your time helping me out on this.
     
  4. aflynn810

    aflynn810

    Joined:
    Feb 26, 2020
    Posts:
    3
    Okay well i created the HealthBar script first this time in my completely new projectand now my PlayerController script isnt recognizing any elements in my player object. What the hell is going on? i Installed the tiny RPG asset from the asset store. Im going to start a completely new one again with out downloading any assets and see if i can get both codes to "work" and show variable slots in the inspector.
     
  5. alexandred_unity

    alexandred_unity

    Unity Technologies

    Joined:
    Dec 12, 2018
    Posts:
    43
    What do you mean by " the variable slot in the inspector"? Do you mean that you see a field editor in the Inspector for your public Slider property?
     
  6. alexandred_unity

    alexandred_unity

    Unity Technologies

    Joined:
    Dec 12, 2018
    Posts:
    43
    Could you share you project (the relevant parts) with us?
     
  7. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    Code (CSharp):
    1. EndLayoutGroup: BeginLayoutGroup must be called first.
    2. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
    I'm having this too when trying to modify the import settings of a texture (atlas) for UI elements in a mobile project set up for Android. It has not prevented me from building though, but I'm optimizing the project to solve certain lag and responsiveness issues that could very well be related to the size and compression of the atlases I rely on (everything happens with a delay that varies in hundreds of milliseconds so that's a lot).

    android_texsettings_crunchetc2rgba_bilinear.png

    I'm using these settings because the "RGBA +1 bit compressed ETC2 4 bits" throws me an error and can't compress (problem with etccompress, code 6).
    The atlases are not produced by Unity but by a small plugin.
    Currently working on MacOs 10.14+ and Unity 2019.4.17f1 LTS.