Search Issue Tracker

Fixed in 2021.2.X

Fixed in 2020.3.X, 2021.1.X

Votes

1

Found in

2019.4

2020.2

2020.2.0b13

2021.1

2021.2

Issue ID

1303188

Regression

No

Multiple errors appear after modifying ScriptableObject's array indirectly

UI Toolkit

-

How to reproduce it:
1. Open the attached project '1303188.zip'
2. Select "New IMGUI Drawer Test.asset"
3. Set the Objects With IMGUI Drawers > Size value to 5
4. Press CTRL + Z (Undo)
5. Observe the Console Window

Expected result: The error doesn't appear in the Console Window
Actual result: The error appears "Retrieving array element that was out of bounds" in the Console Window

Reproducible with: 2019.4.17f1, 2020.2.2f1, 2021.1.0b2, 2021.2.0a2
Could not test with: 2018.4.30f1 (UIElements are not introduced)

Notes:
- Errors appear after adding/removing an item programmatically in the ScriptableObject's array
- Not reproducible after modifying ScriptableObject's array by changing Property Fields values in the Inspector view

  1. Response avatar

    Resolution Note (fix version 2021.2):

    Fixed in 2021.2.0a9

  2. Response avatar

    Resolution Note (fix version 2021.1):

    Fixed in 2021.1.4f1

  3. Response avatar

    Resolution Note (fix version 2020.3):

    Fixed in 2020.3.8f1

Comments (1)

  1. 0ecce5ee28c57b2e3d33720491bd249d?d=mm

    oscarAbraham

    Jan 13, 2021 20:17

    Hello, thanks for taking a look at this issue.

    I wanted to point out that this errors appear in many more cases other than "after undoing the increase of the Serializable array's size". That case was just the easiest example I could think of. The errors are triggered anytime that a property becomes invalid and an IMGUI property drawer is used inside a UIToolkit's PropertyField. That could happen by destroying an object, by changing a managed reference's type, by calling Dispose on a serialized object, etc. It can even happen when reducing an array's size in any place other than directly in the property field.

    I really hope the mechanism behind this bug is not lost in thinking it's just a problem with undoing an array's growth.

    Also, I checked the C# reference in Github. I believe this could be fixed by simply putting "if (!m_SerializedProperty.isValid) return;" in line 104 of PropertyField.cs

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.