Search Issue Tracker

Fixed in 2021.2.X

Votes

0

Found in

2018.4

2019.4

2020.3

2020.3.3f1

2021.1

2021.2

Issue ID

1333052

Regression

No

Value set to serialized fields in OnValidate() method doesn't get displayed correctly in the Inspector window

Serialization

-

Reproduction steps:
1. Open user's project "Prefab test.zip"
2. Select "Master Variant" Prefab in Assets/Prefabs
3. Enter Prefab editing mode by clicking on the "Open Prefab" button in the Inspector window
4. Change the "Test Bool" field of the "Class B" component by clicking on the check box next to it
5. Press Ctrl-S to save the changes
6. Notice that console message gets printed out with the value of serialized field ClassB.testBool
7. Leave the Prefab editing mode by clicking on "Master Variant" Prefab in Assets/Prefabs once again

Expected result: After restoring the "Test Bool" value on the OnValidate method after saving, the Inspector should show the check box checked
Actual result: After restoring the "Test Bool" value on the OnValidate method after saving, the inspector shows the box un-checked, until exiting Prefab editing mode

Reproducible with: 2018.4.35f1, 2019.4.26f1, 2020.3.8f1, 2021.1.7f1, 2021.2.0a16

  1. Response avatar

    Resolution Note (fix version 2021.2):

    Updated docs to reflect that we do not support that a script sets values on other scripts during OnValidate as we cannot guarantee UI stays updated to reflect the values being updated in the prefab.

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.