Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Class with array in second level nested array crashes unity editor

Discussion in 'Editor & General Support' started by AbelSierra, Sep 27, 2021.

  1. AbelSierra

    AbelSierra

    Joined:
    Jul 19, 2018
    Posts:
    19
    Hello, I am having an issue with showing a class with an array in inspector. This class A is used as a property in a class B, the class B is used in an array of a class C, the class C is used in an array of a Monobehaviour.

    The hierarchy is like this and this does not work, it crashes with different errors (see below):
    - MonoBehaviour
    - List<C>
    - List<B>
    - public A; (A contains an array of audio sources)

    But this instead works completely fine:
    - MonoBehaviour
    - List<C>
    - public A; (A contains an array of audio sources)

    Thank you so much for your help!

    The stacktrace of the crashes for the first scenario:

    InvalidOperationException: Queue empty.
    System.Collections.Generic.Queue`1[T].ThrowForEmptyQueue () (at <aa976c2104104b7ca9e1785715722c9d>:0)
    System.Collections.Generic.Queue`1[T].Dequeue () (at <aa976c2104104b7ca9e1785715722c9d>:0)
    UnityEditor.PropertyHandler.IsArrayReorderable (UnityEditor.SerializedProperty property) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.PropertyHandler.UseReorderabelListControl (UnityEditor.SerializedProperty property) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.PropertyHandler.GetHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableList+Defaults.DrawElement (UnityEngine.Rect rect, UnityEditor.SerializedProperty element, System.Object listItem, System.Boolean selected, System.Boolean focused, System.Boolean draggable, System.Boolean editable) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableListWrapper.Draw (UnityEngine.GUIContent label, UnityEngine.Rect r, UnityEngine.Rect visibleArea) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.GenericInspector.OnOptimizedInspectorGUI (UnityEngine.Rect contentRect) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <0fdaf67e8e744beea25e77915c19f81b>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)



    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
    UnityEditorInternal.ReorderableList.GetElementYOffset (System.Int32 index, System.Int32 skipIndex) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableList.GetElementYOffset (System.Int32 index) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableList.GetListElementHeight () (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableList.GetHeight () (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditorInternal.ReorderableListWrapper.GetHeight () (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.PropertyHandler.GetHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.GenericInspector.OnOptimizedInspectorGUI (UnityEngine.Rect contentRect) (at <c9b5231e365148a4bc210cc4e439206d>:0)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <0fdaf67e8e744beea25e77915c19f81b>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)
     
  2. AbelSierra

    AbelSierra

    Joined:
    Jul 19, 2018
    Posts:
    19
    [SOLUTION] Alright, it seems to be a bug in Unity 2020.3.3f1. I have upgraded the project to unity 2020.3.14f1 and it works as intended.