Search Issue Tracker
By Design
Votes
0
Found in
2018.4.0f1
2018.4.1f1
2019.1.0a1
2019.2.0a1
2019.3.0a1
Issue ID
1170729
Regression
No
Prefab property's displayed value does not update when modified by a script
How to reproduce:
1. Open attached 'project-1170729.zip' project
2. In Hierarchy window select 'Box' and inspect its ID value
3. In Assets folder select 'ItemLibrary'
4. In Inspector select Context Menu > 'Save'
5. In Hierarchy window select 'Box' and inspect its ID value
6. In Inspector select 'Open' and inspect prefab's ID value
Expected result: prefab's ID value is '0'
Actual result: prefab's ID value is '5'
Reproducible with: 2018.4.5f1, 2019.1.12f1, 2019.2.0b10, 2019.3.0a11
Could not test with: 2017.4.30f1 and earlier (different prefab interface)
Additional note: the actual value is updated (dragging the prefab into Hierarchy window or re-opening the project will display changed value)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
Resolution Note (2019.3.X):
This case modifies the imported prefab data but does not save it back to source file. So the imported data has become out of sync with the source data since the change was not saved back to the .prefab file. In Prefab Mode we open the .prefab source file that is why the values does not match the modified imported prefab.
Since 18.3 prefabs are imported which means that changing state on a imported Prefab Asset needs to be saved back to the .prefab source file if this changes should be persisted and reflected in existing prefab instances.
Below is an example of how you can save a change back to the prefab source file after changing the imported Prefab Asset:
Modified from ItemLibrary.cs from the repro project:
[ContextMenu("Save")]
public void Save() {
for (int i = 0; i < items.Length; i++) {
if (items[i] != null) {
GameObject itemPrefab = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(items[i]), typeof(GameObject)) as GameObject;
Undo.RecordObject(itemPrefab.GetComponent<ItemObject>(), "Updating Item " + i + " Component");
itemPrefab.GetComponent<ItemObject>().item.ID = i;
PrefabUtility.SavePrefabAsset(itemPrefab); <-- ensures saving change back to the .prefab file.
}
}
}