Search Unity

error with no side effects

Discussion in 'Immediate Mode GUI (IMGUI)' started by Silvia, Aug 24, 2009.

  1. Silvia

    Silvia

    Joined:
    Apr 18, 2009
    Posts:
    23
    I keep on getting the following error while running my game. It happens in the script from where I control the GUI I want to display. However, it only gives me a message in the console, but everything else is working fine; I was nevertheless curious about what it is about...


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

    UnityEngine.GUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) [0x00000]
    GUIistrSecondoGiocoScript.OnGUI () (at Assets/Plugins/GUIistrSecondoGiocoScript.cs:135)
     
  2. ben.dixon

    ben.dixon

    Joined:
    Sep 10, 2009
    Posts:
    8
    Same problem except mine's:

    ArgumentException: Getting control 0's position in a group with only 0 controls when doing repaint
    Aborting

    Anyone have ideas what causes it? I get the error only sometimes when I start Unity and when it occurs it doesn't go away by stopping and re-running the scene. If I close Unity all the way down and restart it, I don't get the error.
     
  3. ben.dixon

    ben.dixon

    Joined:
    Sep 10, 2009
    Posts:
    8
    Correction on my last statement. This morning I've stopped and restarted Unity multiple times and still get the error. Last night, using the same code, I didn't get the error. Seems to be a matter of time. Threading issue?
     
  4. careyagimon

    careyagimon

    Joined:
    Dec 20, 2007
    Posts:
    209
    I might be thinking of something else, so take this with a grain of salt. I seem to remember getting this problem when I had things like various Input class calls in the GUI code. Specifically it would happen if what is being displayed is changed by the Input class inside the OnGUI() call. For example

    Code (csharp):
    1.  
    2. function OnGUI() {
    3.   if(Input.GetMouseButtonDown(0)) {
    4.     GUILayout.Box();
    5.   }
    6. }
    Again, I might be wrong. I can't test this theory right now.
     
  5. rytis

    rytis

    Guest

    Joined:
    Jul 11, 2008
    Posts:
    138
    Would be very helpful if you'd post some small example code that reproduces the problem.

    Most likely you are doing something like this:

    if (conditionThatHappensRandomly)
    SomeGUIControlDrawing

    When Unity is drawing GUI, function OnGUI is called twice on same frame. First call is for layouting and second is for painting or mouse event or whatever.
    The point is that in these two events you need to draw same exact GUI stuff.

    This is wrong:

    Code (csharp):
    1. void OnGUI()
    2. {
    3.   if (Event.current.type == EventType.MouseDown)
    4.       GUILayout.Label("had mouse down"); // <-- will only happen in MouseDown and not Layout event!
    5. }
    This is right:

    Code (csharp):
    1. bool down = false;
    2. void OnGUI()
    3. {
    4.   if (down)
    5.       GUILayout.Label("had mouse down");
    6.  
    7.   if (Event.current.type == EventType.MouseDown)
    8.       down = true;
    9. }
     
    samana1407 likes this.
  6. reallyjoel1

    reallyjoel1

    Joined:
    Feb 2, 2009
    Posts:
    19
    I get this error message when I use a window, and the window id is not the same between each call.

    Our lovely programmers made a 'Utility.NextWindowID', but designer as I am, I called that in OnGUI(), as a param for GUI.Window(), instead of storing it once in Start().

    I can reproduce that error message reliably with having different window id's every OnGUI call.
     
  7. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Please can you file a bug report with an example of this code attached? If it's consistently reproducible, it will help the developers greatly.
     
  8. Cor1312

    Cor1312

    Joined:
    Apr 12, 2010
    Posts:
    34
    Is this bug still being addressed by the developers?
     
  9. rytis

    rytis

    Guest

    Joined:
    Jul 11, 2008
    Posts:
    138
    It's not a bug. It's the way layouted immediate GUI works.

    There are two events:
    - In first one OnGUI is called with Layout event, that way GUI knows what controls are on the screen, how they want to be aligned (e.g. one wants to be stretched full screen width, the other be exactly 300 pixels wide, etc.).
    - Then GUI figures out exact locations and sizes of controls (since second control is 300 pixels wide, and first one wants to stretch, so make first one screenwidth-300 wide, and second 300 pixels wide).
    - OnGUI event is called with Repaint event. Because now control locations and sizes are known, they can actually be drawn.

    If in layout event you don't draw control (don't do e.g. GUILayout.Label), and in the second one you do, GUI will not find an entry in GUI layout table for that control, and throw exception.
     
  10. Cor1312

    Cor1312

    Joined:
    Apr 12, 2010
    Posts:
    34
    That makes perfect sense. However, I am not removing the GUI layout element during the OnGUI() call.

    (This code was adapted from AngryAnt's drag and drop example.)

    public void OnGUI() {

    GUI.depth = 0;

    rectObject.x = startPosition.x;
    rectObject.y = startPosition.y;

    GUILayout.BeginArea(rectObject); //error here

    GUILayout.Box(texDataObject, styleDataObject);

    rectDrag = GUILayoutUtility.GetLastRect();

    GUILayout.EndArea();

    rectDrag.x = rectDrag.x + startPosition.x;
    rectDrag.y = rectDrag.y + startPosition.y;

    if (this.MouseUp) {
    this.ResetStatus(); //resets a boolean variable
    }

    Drag(rectDrag);

    }

    Also, I seem to only getting the error on only 1 of these objects that are on the screen.
     
  11. rytis

    rytis

    Guest

    Joined:
    Jul 11, 2008
    Posts:
    138
    Can you somehow put up a minimal complete project that reproduces? Since I cannot tell what the code in your function Drag and others do. It would be greatly helpful if you'd make a small Unity project that shows the bug, report it through bug reporter, and write me (here or mail) the case number.
     
  12. Cor1312

    Cor1312

    Joined:
    Apr 12, 2010
    Posts:
    34
    Thanks for the replies Rytis.

    After stripping down my code, I was unable to reproduce the error. I will do a more intensive bug search later in the week. Will update if I come across anything.
     
  13. metaone

    metaone

    Joined:
    Jun 15, 2010
    Posts:
    1
    Hi,
    I had the same issue with a progress bar supposed to automatically change to the main menu once some stuff done.

    I solve my issue by using the line:

    Code (csharp):
    1.  
    2. yield WaitForEndOfFrame();
    3.  
    OnGui skeleton:

    Code (csharp):
    1.  
    2. public OnGui(){
    3.   // building the Gui using GUILayout
    4.   if (state==0){
    5.     GUILayout.Label("loading data");
    6.     yield WaitForEndOfFrame();
    7.     // test and gui change
    8.     if (something) {state=1;}
    9.   }
    10.   else {
    11.     if (GUILayout.Button("start")){
    12.     //...
    13.     }
    14.   }
    15. }
    16.  
    that's it!
     
  14. rytis

    rytis

    Guest

    Joined:
    Jul 11, 2008
    Posts:
    138
    Hi, I don't know why it solved your issue, but it's really not "it".


     
    AustinRichards likes this.
  15. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    I'm having the same error in this code:
    Code (csharp):
    1. function OnGUI() {
    2.     if ((DialogueGlobals.dialogueIsInterruptible  DialogueGlobals.currentDialogueObject != gameObject  !isRandomLoop)) {
    3.         DestroyImmediate(DialogueGlobals.currentDialogueObject);
    4.         DialogueGlobals.dialogueIsInterruptible = isInterruptible;
    5.         DialogueGlobals.currentDialogueObject = gameObject;
    6.     } else if (DialogueGlobals.currentDialogueObject == gameObject || isRandomLoop) {
    7.         if (!isRandomLoop  CursorHandlerScript.cursor != CursorHandlerScript.mechanicalCursorStatic) {
    8.             CursorHandlerScript.cursor = CursorHandlerScript.mechanicalCursorStatic;
    9.         }
    10.        
    11.         //Create events, if any
    12.         if (checkEvents) {
    13.             checkEvents = false;
    14.             for (i = 0; i < eventTriggerFrames.length; i++) {
    15.                 if (eventTriggerFrames[i] == dialogueSequencePosition) {
    16.                     eventTriggerObjects[i].GetComponent(eventTriggerObjects[i].name + "_TriggeredScript").ClickTriggeredFunction(gameObject);
    17.                 }
    18.             }
    19.         }
    20.        
    21.         //Get the screen position of the speaker object
    22.         var dialogueScreenPosition = GetScreenPositionGlobals.GetScreenPosition(dialogueSpeaker, GameObject.FindWithTag("MainCamera").camera);
    23.         dialogueScreenPosition.y =  Screen.height - dialogueScreenPosition.y;
    24.        
    25.         //Create the dialogue bubble
    26.         GUILayout.BeginArea(Rect(screenEdgePadding, screenEdgePadding, Screen.width-(screenEdgePadding*2), Screen.height-(screenEdgePadding*2)));
    27.            
    28.             GUILayout.BeginHorizontal();
    29.                
    30.                 GUILayout.FlexibleSpace();
    31.                
    32.                 GUILayout.BeginVertical();
    33.                    
    34.                     GUILayout.FlexibleSpace();
    35.                    
    36.                     GUILayout.Box(dialogueList[dialogueSequencePosition], textBubbleStyle);
    37.                    
    38.                     GUILayout.Space(Screen.height-dialogueScreenPosition.y+offsetY-screenEdgePadding);
    39.                    
    40.                 GUILayout.EndVertical();
    41.                
    42.                 GUILayout.Space(Screen.width-dialogueScreenPosition.x-offsetX-screenEdgePadding);
    43.                
    44.             GUILayout.EndHorizontal();
    45.            
    46.         GUILayout.EndArea();
    47.        
    48.        
    49.         //Is it randomly looping, or does it need a button so the player can cycle through?
    50.         if (isRandomLoop) {
    51.             timer += Time.deltaTime;
    52.             if (timer >= randomChangeTiming) {
    53.                 timer = 0.0;
    54.                 dialogueSequencePosition = Random.Range(0, dialogueList.length);
    55.             }
    56.         } else if (GUI.Button(Rect(0, 0, Screen.width, Screen.height), "", invisibleButtonStyle)) {
    57.             dialogueSequencePosition++;
    58.             checkEvents = true;
    59.            
    60.             //End of dialogue check
    61.             if (dialogueSequencePosition == dialogueList.length) {
    62.                 if (stopsPlayer) {
    63.                     PlayerControllerGlobals.movementMode = MovementModes.Walking;
    64.                 }
    65.                 if (disablesClicks) {
    66.                     PlayerControllerGlobals.playerCanClick = true;
    67.                 }
    68.                
    69.                 if (triggeringObject) {
    70.                     triggeringObject.GetComponent(DialogueDisplayer_TriggeredScript).isActive = true;            
    71.                 }
    72.                
    73.                 CursorHandlerScript.cursor = CursorHandlerScript.normalCursorStatic;
    74.                
    75.                 DialogueGlobals.dialogueIsInterruptible = true;
    76.                 DestroyImmediate(gameObject);
    77.             }
    78.         }
    79.     }
    80. }
     
  16. Barry Holroyd

    Barry Holroyd

    Joined:
    Mar 21, 2009
    Posts:
    17
    Hi All,

    Based on rytis' comments I've created a very simple script which demonstrates the issue clearly. It appears that on even numbered calls to OnGUI, GUILayout expects to have the layout already available (i.e., to have been called on the previous (odd numbered) OnGUI call).

    In the example below, the second call doesn't call GUILayout but that's o.k. -- the layout is available but unused. However, on the seventh call it also gets skipped, causing an error on the eighth call since the layout is needed but unavailable at that time.

    I've also attached a package containing this.

    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public class GuiTest : MonoBehaviour
    4. {
    5.     // On even passes, GUILayout expects to already know the layout (i.e., to have
    6.     // been called already on the first pass).
    7.     int onGUIcalls = 1;
    8.     void OnGUI()
    9.     {
    10.         switch (onGUIcalls)
    11.         {
    12.             case 1: button(true); break;
    13.             case 2: button(false); break;   // does not cause failure; just doesn't display button
    14.             case 3: button(true); break;
    15.             case 4: button(true); break;
    16.             case 5: button(true); break;
    17.             case 6: button(true); break;
    18.             case 7: button(false); break;   // will cause failure on the next pass
    19.             case 8: button(true); break;
    20.             case 9: button(true); break;
    21.             case 10: button(true); break;
    22.             default: button(true); break;
    23.         }
    24.         onGUIcalls++;
    25.     }
    26.     void button (bool b)
    27.         {
    28.             if (b)
    29.             {
    30.                 Debug.Log(onGUIcalls + ". button: YES");
    31.                 GUILayout.Button("Button 1");
    32.             }
    33.             else
    34.                 Debug.Log(onGUIcalls + ". button: NO");
    35.         }
    36. }
    Barry
     

    Attached Files:

  17. nandobang

    nandobang

    Joined:
    Apr 6, 2010
    Posts:
    26
    Hi folks,

    Dunno if anybody solved this, but I've faced it and took me quite some time to figure out the solution.
    Thanks to rytis for his explanation on how GUI is rendered, I've came up with a simple workaround.

    The problem occurs when you have a condition for rendering a group of GUI stuff. As you can't just put in the condition, because of the Layout and Repaint stages of the event, your condition must met these two guys. Let's say this is your piece of code (C#):

    Code (csharp):
    1.  
    2. void OnGUI()
    3. {
    4.  
    5. if (someExternalVariable > 0.1f)
    6. {
    7. GUILayout.Label("Your name");
    8. name = GUILayout.TextField(name);
    9. }
    10.  
    11. }
    12.  
    This piece will throw an error like this:

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

    Any time you change the value of someExternalVariable. The solution is quite simple:

    Code (csharp):
    1.  
    2. private float externalVariableController = 0.0f;
    3. private int innerController = 0;
    4.  
    5. void OnGUI()
    6. {
    7.  
    8. if (externalVariableController > 0.1f)
    9. {
    10. GUILayout.Label("Your name");
    11. name = GUILayout.TextField(name);
    12. }
    13.  
    14. if (Event.current.type == EventType.Layout)
    15. {
    16. innerController = 1;
    17. }
    18.  
    19. if (Event.current.type == EventType.Repaint)
    20. {
    21. innerController = 2;
    22. }
    23.  
    24. if (innerController == 2)
    25. {
    26. externalVariableController = someExternalVariable;
    27. innerController = 0;
    28. }
    29.  
    30. }
    31.  
    What happens here is that instead of using directly the someExternalVariable to control our condition for rendering the GUI, we create a controller. This controller (it's just a way to call it) will hold the current state of the GUI Event. Once it passes the Layout stage and gets to Repaint, it makes a backup of the someExternalVariable so we can use it in our condition. This assures that GUI will always have time to read the layout again, even if the content changes.

    I've tested it 5 minutes ago, and works, no more errors from Layout event stage. I hope this helps someone.
     
  18. KevS

    KevS

    Joined:
    Apr 21, 2010
    Posts:
    51
    I'm embarassed, you give a solution but i dont understand how to use it.

    I'm working on a chat for a lobby room. I took a look on the M2H tuto and Unity Networking to have some idea but i have style this error when i "submit" a new message. Here is my code :

    Code (csharp):
    1.  
    2.  
    3. public void OnGUI()
    4. {
    5.         chatScrollPosition = GUILayout.BeginScrollView(chatScrollPosition, GUILayout.Width(500), GUILayout.Height(200));
    6.         foreach (ChatEntry entry in chatEntries)
    7.         {
    8.             GUILayout.BeginHorizontal();
    9.             if (entry.name == "")
    10.             {
    11.                 GUILayout.Label(entry.text);
    12.             }
    13.             else
    14.             {
    15.                 GUILayout.Label(entry.name + ": " + entry.text);
    16.             }
    17.             GUILayout.EndHorizontal();
    18.             GUILayout.Space(3);
    19.         }
    20.         GUILayout.EndScrollView();
    21.         Event e = Event.current;
    22.         if (e.keyCode == KeyCode.Return  inputField.Length > 0)
    23.         {
    24.             SubmitMsg(inputField);
    25.         }
    26.         inputField = GUILayout.TextField(inputField);
    27. }
    28.  
    Code (csharp):
    1.     public void SubmitMsg(string msg)
    2.     {
    3.         msg = msg.Replace("\n", "");
    4.         networkView.RPC("NewChatEntry", RPCMode.All, playerName, msg);
    5.         inputField = ""; //Clear line
    6.     }
    I figure out that in my case when i submit a new message, the "chatEntries" list has a new item and so a new GUILayout.Label will be painted without be layouted. I tried to "block" the painting until next frame, but i didn't succeed. Do you have some idea ?
    Thanks
     
  19. nandobang

    nandobang

    Joined:
    Apr 6, 2010
    Posts:
    26
    Hello there!

    In the code you've posted, I assume that "chatEntries" is a variable you are accessing from outside this OnGUI. If so, this should solve it:
    - Define a variable that will represent your "chatEntries" in the class you have the OnGUI;
    - Instead of the "chatEntries", use this variable in the OnGUI;
    - Check my code. Try to use those 3 last "if" conditions. They are responsible for updating the variable with the real "chatEntries" data ONLY if the GUI has already completed the Layout and Repaint events, thus it will have fresh data in a fresh GUI cycle.

    Tell me if you have any difficulties, and good luck!
     
  20. KevS

    KevS

    Joined:
    Apr 21, 2010
    Posts:
    51
    Thank you for your reply, and i think i found a solution similar of yours.
    I have now a temporary variable which is a copy of my "chatEntries". This copy is done in the Update fonction, and i use this copy in the OnGUI function to draw Label instead of the "chatEntries" variable. In that way, when "chatEntries" is modified by an event in the OnGUI fonction, the copy is not updated until the next frame and the error disappear ^^.
     
  21. nandobang

    nandobang

    Joined:
    Apr 6, 2010
    Posts:
    26
    Well, that is pretty clever! :D
    Haven't thought that way before. Update runs once per frame, while OnGUI runs many times per frame.

    Now, it's my time to thank you!
     
  22. Ultimatemau

    Ultimatemau

    Joined:
    Mar 1, 2011
    Posts:
    17
    I can confirm that NandoBang has solved the problem. This problem occurs when using GUILayout and not when using GUI.

    Thnx rytis and NandoBang.

    Cheers
     
  23. Santtu-S

    Santtu-S

    Joined:
    Jul 9, 2012
    Posts:
    26
    Hi (first post aye),

    I was creating a more or less dynamic editor (MDI type) and came across this same problem.

    I made a small class to help with this problem that works pretty well, basically it combines stuff said in this thread and forces the condition to go through the layout-repaint cycle before actually changing state. It works kind of like normal bool type. It also forces a repaint so the changes will come out quickly.

    Here's the class

    Code (csharp):
    1.  
    2. public class GUICondition
    3.     {
    4.        
    5.         protected byte state = 0;
    6.         protected bool condition;
    7.         protected bool oldValue;
    8.        
    9.         public bool Value
    10.         {
    11.             get
    12.             {
    13.                 return oldValue;
    14.             }
    15.         }
    16.  
    17.         public bool Condition(bool condition)
    18.         {
    19.             bool toReturn = oldValue;
    20.             switch(state)
    21.             {
    22.             case 0 :
    23.                 if (oldValue != condition)
    24.                 {
    25.                     this.condition = condition;
    26.                     state = 1;
    27.                     if (EditorWindow.focusedWindow != null)
    28.                     {
    29.                         EditorWindow.focusedWindow.Repaint();
    30.                     }
    31.                 }
    32.                 break;
    33.             case 1 :
    34.                 if (Event.current != null  Event.current.type == EventType.Layout)
    35.                 {
    36.                     state = 2;
    37.                     if (EditorWindow.focusedWindow != null)
    38.                     {
    39.                         EditorWindow.focusedWindow.Repaint();
    40.                     }
    41.                 }
    42.                 break;
    43.             case 2 :
    44.                 if (Event.current != null  Event.current.type == EventType.Repaint)
    45.                 {
    46.                     state = 3;
    47.                 }
    48.                 break;
    49.             case 3 :
    50.                 oldValue = this.condition;
    51.                 toReturn = this.condition;
    52.                 state = 0;
    53.                
    54.                 break;
    55.             }
    56.             return toReturn;
    57.         }
    58.        
    59.         public GUICondition(bool initial)
    60.         {
    61.             this.condition = initial;
    62.             this.oldValue = initial;
    63.         }
    64.        
    65.         public static implicit operator GUICondition(bool initial)
    66.         {
    67.             return new GUICondition(initial);
    68.         }
    69.        
    70.         public static implicit operator bool(GUICondition state)
    71.         {
    72.             return state.Value;
    73.         }
    74.        
    75.     }
    76.  
    To use it "normally" one would do like this :
    Code (csharp):
    1.  
    2. // initialization
    3. GUICondition check = false;
    4. // ... lots of layout code
    5. bool addStuffToGUI = (some condition);
    6. // ... lots of more layout code
    7. if (check.Condition(addStuffToGUI) {
    8.   // Add MORE stuff to GUI...
    9. }
    10.  
    One can use it with the intermediate GUI stuff too

    Code (csharp):
    1.  
    2. // Initialization
    3. GUICondition showGeneral = false;
    4. // ...
    5. if (showGeneral.Condition(EditorGUILayout.Foldout (showGeneral, "General"))) {
    6.   // Add stuff to GUI
    7. }
    8.  
    Hope it helps...

    Just a quick edit, sometimes you have to double check the if in first example because the GUICondition comes at least 3 frames late (which is what it is supposed to do, since the condition is only "when to draw stuff")... So if you check for example a null, then do this :

    Code (csharp):
    1.  
    2. if (showBuilderSection.Condition(selectedBuilder != null)) {
    3.   if (selectedBuilder != null) {
    4.     // Do the stuff here
    5.   }
    6. }
    7.  
     
    Last edited: Jul 9, 2012
  24. jonesvg

    jonesvg

    Joined:
    Jul 29, 2010
    Posts:
    27
    Hi friends, i have this error about Repaint in this code


    Code (csharp):
    1. private void renderRefreshButton()
    2.         {
    3.             GUIStyle s = new GUIStyle(uiGUI.Style("muraBreadcrumbRefresh" + (modalMode ? "Simple" : "")));
    4.                
    5.                 s.padding.left = 0;
    6.                 s.padding.right = 32;
    7.                 s.border.left = 0;
    8.                 s.border.right = 30;
    9.            
    10.             uiCore.Instance.setupGUIColor();
    11.            
    12.            
    13.                 GUILayout.BeginHorizontal(s, GUILayout.MaxWidth(40));
    14.                
    15.                 uiCore.Instance.resetGUIColor();
    16.                
    17.                 GUILayout.FlexibleSpace();
    18.                 s = new GUIStyle(uiGUI.Style("muraBreadcrumbButton"));
    19.                
    20.                 s.fixedWidth = 20;
    21.                
    22.                 uiCore.Instance.setupGUIMenuColor();
    23.                
    24.                 if (GUILayout.Button(MuraSkinResources.GetInstance().getResource("reloadIcon"), s))
    25.                 {
    26.                     refreshSection((Section)currentSection);
    27.                 }
    28.                
    29.                 uiCore.Instance.resetGUIColor();
    30.                
    31.                 GUILayout.EndHorizontal();
    32.            
    33.         }
    34.  
    The unity clains error in this part GUILayout.BeginHorizontal(s, GUILayout.MaxWidth(40));

    Some one help he he he
     
  25. Loius

    Loius

    Joined:
    Aug 16, 2012
    Posts:
    546
    Your GUI's state is changing between Layout calls.

    renderRefreshButton is being called conditionally and the condition changes at the wrong time in the GUI cycle for GUI to catch up.

    You have to change how you change the condition.

    This code probably won't show the same problem, but it's an example:
    Code (csharp):
    1. function Update() {
    2.   showButton = !showButton;
    3. }
    4.  
    5. function OnGUI() {
    6.   if ( showButton ) GUILayout.BeginHorizontal();
    7.   GUILayout.Button("Button");
    8.   if ( showButton ) GUILayout.EndHorizontal();
    9. }
    That might get layouting errors when showButton changes at the wrong time. To fix it:

    Code (csharp):
    1. function OnGUI() {
    2.   if ( GUILayout.Button("Add Horizontal") ) showButton = !showButton;
    3.   // etc.
    4. }
     
  26. jonesvg

    jonesvg

    Joined:
    Jul 29, 2010
    Posts:
    27
    Thanks friend, i see the bug.
     
  27. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    I know this is an old thread, but I too had this error message recently. It was occurring in a cascade of conditionals which would display information dependent on external variables. What "seems" to have resolved it, was by modifying an EditorGuiLayout.BeginHorizontal(); call in one of my conditions to include a Foldout. Which seems odd, because I had never got the error prior to today... it just seems that something got out of sync between the OnGUI conditionals, and the OnInspector (){ Repaint();} call.


    [edit]

    looks like that was not the fix, but rather I had a button in a certain check that when starting playmode, I would get the error message. If I commented out:

    button = EditorGUILayout.GetControlRect(GUILayout.MaxWidth(80));

    (which was to set a width supposedly based on the control area (?))... commenting it out causes the error to go away. I'm not 100% sure this is a fix, but seems to be working now.
     
    Last edited: May 31, 2014