Search Issue Tracker
By Design
Votes
1
Found in
2018.3.0a6
2018.3.2f1
2019.1.0a1
2019.2.0a1
Issue ID
1129930
Regression
Yes
Prefab Asset changes are not reflected inside Prefab Editor when changes are made to Prefab Asset reference variable in a Script
Reproduction steps:
1. Open the project inside of "case_1129930-TESTChangePrefab_Unity.zip"
2. Take a look at "2D Prefab" asset through Prefab Editor and pay attention to its colour
3. Open the "SampleScene" and Play it
4. Add "2D Prefab" to the canvas, notice that it is red
5. Open the Prefab Editor again
Expected: The Prefab Editor shows, that the "2D prefab" is red
Actual: The Prefab Editor shows, that the "2D prefab" is white
Reproduces on: 2018.3.0a6, 2018.3.7f1, 2019.1.0b4, 2019.2.0a6
Does not reproduce on: 2017.4.20f2, 2018.3.0a5
Note:
- Prefab Asset restores to its former state if the Project is restarted, which is likely intended because the prefab is not marked as dirty
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
- Crash on __pthread_kill when initializing Vuplex WebView while entering the Play Mode
- Crash on FindSurface when adding a custom Renderer Feature to a 2D Renderer Data Asset
- [Android] [Vulkan] [UI Toolkit] Application crashes when the device is rotated when it has UI Toolkit TextField on Vulkan devices
- Crash on DualThreadAllocator<DynamicHeapAllocator>::TryDeallocate when opening a specific project
- Crash on memset_repstos when pressing a UI button while in Play Mode
Resolution Note (2019.2.X):
This example here modifies the imported prefab data but does not save it back to source file. So here 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 it is still white (and not red as the unsaved imported prefab asset)
Since 18.3 prefabs are imported this 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.
Below is an example of how you can save a change back to the prefab source file when changing the imported Prefab Asset:
Modified from TestColorChange.cs in the repro project:
private void Start()
{
prefab.GetComponent<Image>().color = color1;
#if UNITY_EDITOR
// If the 'prefab' reference above points to an imported Prefab Asset we need to save the change
// back to the .prefab source file if we want this change persisted. (We are not modifying the
// source file but the imported data here). In Prefab Mode we always open the prefab from the
// .prefab file.
if (EditorUtility.IsPersistent(prefab))
PrefabUtility.SavePrefabAsset(prefab);
#endif
GameObject go = Instantiate(prefab, transform);
}