Search Issue Tracker

By Design

Under Consideration for 2021.3.X, 2022.3.X, 2023.2.X, 2023.3.X

Votes

0

Found in

2021.3.33f1

2022.3.14f1

2023.2.2f1

2023.3.0a16

Issue ID

UUM-57223

Regression

No

List items wrongly initialized in the Inspector when values are declared in the constructor

--

-

How to reproduce:
1. Open the attached project "90_develop.zip"
2. Select "Test" in the Inspector window
3. Add a new Element to the "Items" list in the Inspector window

Expected results: "Var 1" and Var 2" are set to "10" and "20"
Actual results: "Var 1" and Var 2" are both set to "0"

Reproducible with: 2021.3.33f1, 2022.3.14f1, 2023.2.2f1, 2023.3.0a16

Reproducible on: Windows 11 22H2
Not reproducible on: No other environment tested

  1. Resolution Note:

    Thank you for reporting a bug to Unity.

    When the first element is added to an array via SerializedProperty it is allocated by zeroing the memory rather than calling the constructor. And when adding additional elements it copies the previous element. We will consider changing that behavior as part of future quality improvement work in the area of SerializedObject/SerializedProperty but also wary of any possible performance and backward compatibility impact for changing this behaviour.

    Today we will be closing this case. Thank you again for taking the time to report this issue

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.