ArgumentException: Getting control 1's position in a group with only 1 controls when doing Repaint

Getting this weird error

ArgumentException: Getting control 1's position in a group with only 1 controls when doing Repaint Aborting UnityEngine.GUILayoutGroup.GetNext () UnityEngine.GUILayoutUtility.BeginLayoutArea (UnityEngine.GUIStyle style, System.Type LayoutType) UnityEngine.GUILayout.BeginArea (Rect screenRect, UnityEngine.GUIContent content, UnityEngine.GUIStyle style) UnityEngine.GUILayout.BeginArea (Rect screenRect) Dicemanager.displayStandardScreen () (at Assets/Dice Resources/Dicemanager.js:303) Dicemanager.OnGUI () (at Assets/Dice Resources/Dicemanager.js:455)

I saw a similar posts that says something about two passes but I frankly dont understand it. The problem if I set a value that influences whether a pop up (GUI screen) will be displayed some time later. But the fault doesnt occur when conditions are right for the pop up but immediately after the variable is set.

Condition is really hard to explain but I was wondering if someone could maybe throw some light to the error message.

Ok. I solved this by setting the variable in a different place. The variable effected when part of the GUI would be displayed. I cant pretend I understand exactly which but the clue I got from the other post was that it ran two passes across the GUI code. My guess is when I set the variable it meant that the second pass wouldnt display that would have been displayed in the first pass.

Another reason ArgumentException can be happening is from trying to use EditorGUILayout functions in PropertyDrawers. It turns out the documentation for PropertyDrawer says:

Note that for performance reasons, EditorGUILayout functions are not usable with PropertyDrawers.

It used to work for me back on 2018, but it seems that Unity’s changed something on 2019 and using EditorGUILayout always causes this ArgumentException.