Search Issue Tracker

By Design

Votes

0

Found in

2020.3.40f1

2021.3.13f1

2022.1.22f1

2022.2.0b14

2023.1.0a18

Issue ID

UUM-19289

Regression

No

The Prefab instance values are not saved when resetting them with the custom button in the Inspector

--

-

Steps to reproduce:
1. Open the project “Unity 2022.1.19f1 - Custom editor button changing vector list on prefab instance lets 0 revert on Play Exit”
2. Open the “SampleScene” Scene
3. Select “ListOfPoints” GameObject in the Hierarchy
4. Click the “Reset all values to zero” button in the Inspector
5. Enter Play mode
6. Observe the Inspector

Expected result: The values remain 0
Actual result: Some values changed back to 99 (The changed values are the ones that are 0 in the original Prefab)

Reproducible with: 2020.3.40f1, 2021.3.13f1, 2022.1.22f1, 2022.2.0b14, 2023.1.0a18

Reproduced on: macOS Monterey 12.5.1 (Intel)

Notes:
- Git also does not track the values reset
- Not reproducible with “ListOfPoints (1)” GameObject because it is a non-prefab instance

  1. Resolution Note:

    Hi, please check out the documentation for recording undo on Prefab instances. Following the example will make entering Play mode work correctly.
    https://docs.unity3d.com/ScriptReference/PrefabUtility.RecordPrefabInstancePropertyModifications.html

    It should follow this pattern:
    Undo.RecordObject(script, "Reset all values to zero");

    //Set values here
    ...

    PrefabUtility.RecordPrefabInstancePropertyModifications(script);

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.