Argument Exceptions in many of our existing CustomEditors once odin imported

Issue #72 resolved
Former user created an issue

The exceptions only show up once the object is selected and the inspector is drawn.

rather than trying to find broken ones and disable odin, it was easier just to disable odin for everything :(

[Exception] ArgumentException: GUILayout: Mismatched LayoutGroup.Repaint 0. UnityEngine.GUILayoutUtility.BeginLayoutGroup() C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:301 1. UnityEditor.EditorGUILayout.BeginHorizontal() C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7234 2. UnityEditor.EditorGUILayout.BeginHorizontal() C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7214 3. UnityEditor.EditorGUILayout.LabelField() C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:5646 4. UnityEditor.EditorGUILayout.LabelField() C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:5596 5. FearEditor.DoFears() Assets/Scripts/GamePlay/AI/Fear/Editor/FearEditor.cs:58 6. FearEditor.OnInspectorGUI() Assets/Scripts/GamePlay/AI/Fear/Editor/FearEditor.cs:49 7. UnityEditor.InspectorWindow.DrawEditor() C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1229

Comments (6)

  1. Tor Esa Vestergaard
    • changed status to open

    That's really weird - Odin doesn't touch Unity's code at all, and I don't see any Odin-related calls anywhere in that stack trace. I can't imagine what is going on that Odin might break your completely non-Odin related editor - are you sure the error only happens with Odin installed? We'll try to replicate this, but we may need to ask for some of your code in order to reproduce it, if it is indeed Odin's fault.

  2. Tor Esa Vestergaard

    So far we've been unable to determine what might be causing this. Could you please post the contents of the FearEditor class?

  3. Tor Esa Vestergaard

    We've also made a few changes that might conceivably fix this - if you give us your email, we can send you the latest build so you can try it out.

  4. mike diskett

    OP here. It is Odin - issue started as soon as we added odin, issue went away as soon as I deleted odin, or disabled odin from working with any user classes. (Email dizzy2003@gmail.com am in Australia so beware time difference if you dont get a reply straight away)

    But as usual nothings simple :) I made a stand alone test case with a project of just Odin and the fear class, worked fine (well no exceptions, there was one weird issue of two text labels that normally appear fine were overlapping)

    So I figure its some weird interaction with something else, possibly some other component on the object. So I deleted all other components in the original error case, exception still gets spammed.

    So as of right now I'm unable to isolate a test case that reproduces the issue, but nor am I able to use odin (the user prefs not saving bug stops me being able to disable the non odin user classes). So I have deleted odin from our main project.

    BTW this was all on unity 5.6.0p1

    Will try to take another look today, but I've all ready burnt 4 hours on this, and I was buying odin to save time ;)

  5. Tor Esa Vestergaard

    Alright, I've been playing around with the project you sent me, and it really helped having the code that caused the issue right at hand! I tracked down the error fairly promptly and implemented a fix. I'll send you a mail with a build that has the fix.

    This was a bit of a tricky one. In your custom editor, you were inspecting a list of Unity objects, with each element being expandable, and when you expanded the element, you created an editor for it and drew that editor.

    The issue was that you were creating new editor instances every GUI event frame, and the type you were creating editors for was being inspected by Odin, so you had a new, fresh Odin editor spawned every frame.

    The problem comes because the OdinEditor type tries to be smart - it won't start drawing anything until it's seen its first layout, so that you can technically spawn one in repaint and keep using it. However, since you're creating a new instance of the editor type every frame, it will always draw in every layout, but never in repaint. Thus you will start getting layout exceptions after having called OnInspectorGUI on the Odin editor in repaint, since it won't have drawn anything while waiting for its first layout, and the layout system will be expecting it to draw everything. No Odin anywhere in the stack trace, hence why this one was so tricky to figure out without sitting with the code ourselves :)

    Our fix is removing this waiting-for-layout behaviour from OdinEditor - it will now draw whenever you invoke OnInspectorGUI on it, regardless of the current event type. The onus is now on the creator of the editor instance to make sure that the calls always come in the right events. This also conforms better with the standard way Unity editors act, so it really is better all around.

  6. Log in to comment