Search Issue Tracker
By Design
Votes
0
Found in
5.4.0b12
Issue ID
784685
Regression
No
Changes made to instance of prefab aren't recorded if previously SetActive was called on that prefab
Steps to reproduce:
1. Open attached project
2. Open "Editor/ShowBug.cs" script
3. Script creates instance of prefab, then prefab has SetActive(true) called and after that sets transform.position the instance
4. Go back to editor and in top menu, click "Show > Bug"
5. Notice that instance of "GameObject" prefab is created
6. Inspect newly created instance and notice that transform.position is 0, 0, 0 although it was set to 1, 1, 1 in the script
7. In console, notice that output message states that transform.position of instance is 1, 1, 1
Additional steps:
8. In "ShowBug.cs" script, comment out SetActive(true) statement
9. In editor, create instance of prefab again and notice that this time transform.position is 1, 1, 1
Workaround: Call PrefabUtility.RecordPrefabInstancePropertyModifications for each property that was changed. Please note that calling it directly on game object is not enough: as an argument to the method you have pass "instance.transform", "instance.GetComponent<Rigidbody>()", etc.
Reproduced with: 5.1.4f1, 5.2.4f1, 5.3.4p1, 5.4.0b13
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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note (2018.3.X):
It is by design. Reference: https://docs.unity3d.com/ScriptReference/PrefabUtility.RecordPrefabInstancePropertyModifications.html