Search Issue Tracker

Duplicate

Votes

7

Found in

2020.3.31f1

2020.3.32f1

2021.2.15f1

2021.3

Issue ID

1414987

Regression

Yes

Error "GetElementHeight called with index 0 but array only has 0 element(s)." when list has no element

Scripting

-

How to reproduce:
1. Open the user's attached project "EmptyReorderableListBug.zip"
2. Open the Inspector window
3. Select the "Some Scriptable Object" asset in "Assets" > "Data" folder
4. Observe the Console window

Expected result: No error occurs
Actual result: Error "GetElementHeight called with index 0 but array only has 0 element(s)." occurs

Reproducible with: 2020.3.31f1, 2020.3.32f1, 2021.2.15f1, 2021.2.17f1, 2021.3.0f1
Not reproducible with: 2019.4.37f1, 2020.3.30f1, 2021.2.14f1, 2022.1.0b14, 2022.2.0a9

Notes:
- Reproducible if the Inspector window is opened
- Error in Console: "GetElementHeight called with index 0 but array only has 0 element(s).
UnityEngine.Debug:LogError (object)
SomeScriptableObjectEditor:GetElementHeight (int) (at Assets/Scripts/Editor/SomeScriptableObjectEditor.cs:28)
UnityEditorInternal.ReorderableList:CacheIfNeeded () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:548)
UnityEditorInternal.ReorderableList:GetListElementHeight () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:740)
UnityEditorInternal.ReorderableList:GetListElementHeight () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:751)
UnityEditorInternal.ReorderableList:DoLayoutList () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:693)
SomeScriptableObjectEditor:OnInspectorGUI () (at Assets/Scripts/Editor/SomeScriptableObjectEditor.cs:36)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)"

Comments (1)

  1. HarryCodder

    Apr 05, 2022 09:43

    Please backport this fix on the LTS branches as well.

Add comment

Log in to post comment