Search Issue Tracker

By Design

Votes

6

Found in

2021.3.33f1

2022.3.15f1

2023.2.4f1

2023.3.0a19

6000.0.0b11

Issue ID

UUM-58993

Regression

No

Prefab overrides of children GameObjects with identical names are not saved when overwriting Prefab with PrefabUtility.SaveAsPrefabAsset

-

Reproduction steps:
1. Open the “ReproProject“ project
2. Open the “Assets/Scenes/SampleScene“ scene
3. Drag and drop the “Assets/TestPrefab“ Prefab into the Hierarchy window
4. Change the Tag to “EditorOnly“ of all the children GameObjects of the “TestPrefab“ GameObject in the Inspector window
5. Select the “TestPrefab“ GameObject in the Hierarchy window
6. Open the “Overrides” Dropdown in the Inspector window
7. Observe the children GameObjects Overrides
8. Overwrite the Prefab (Assets > GeneratePrefab)
9. Repeat steps 5, 6, 7

Expected result: All children GameObjects of the “TestPrefab“ GameObject have the “EditorOnly” tag Override
Actual result: Children GameObjects with identical names of the “TestPrefab“ GameObject are missing from the Override list

Reproducible with: 2021.3.33f1, 2022.3.15f1, 2023.2.4f1, 2023.3.0a19

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

  1. Resolution Note:

    In this case the user creates an entirely new Prefab with the same structure as the existing Prefab. The objects in the new Prefab have different IDs and the overrides can't be applied.

    We try to keep as many overrides as possible by setting the IDs of the new objects in the new Prefab to the same values as in the existing Prefab using name matching, but this fails when there are duplicate names. We deliberately don't consider the order of the objects when doing name matching to be able to match reordered objects. The matching algorithm is not perfect, but considering the order will break when new objects are inserted in the hierarchy

Add comment

Log in to post comment