Search Issue Tracker

By Design

Votes

0

Found in

2018.3.0f2

Issue ID

1122921

Regression

No

Object reference is lost when using PrefabUtility.SaveAsPrefabAssetAndConnect in Play mode

Scene Management

-

To reproduce:
1. Open the project attached "616073-201830f2-prefab-save.zip", scve
2. In Hierarcy window, sleect GameObject
3. In Inspector window, drag "Main Camera" to Obj property field in Test Prefab Component, apply prefab override
4. Enter Play mode, modify the value of 'Age' and click SaveAsPrefabAssetAndConnect
5. Exit Play mode and check Obj property of GameObject

Expected: prefab reference remains referenced in the property field
Actual: property field is empty (reference lost)

Reproduced in: 2018.3.7f1, 2019.1.0b6, 2019.2.0a7

Note: 2019.2.0a7 throws error when executing:

Save prefab failed.
UnityEngine.Debug:LogError(Object)
TestPrefabInspector:OnInspectorGUI() (at Assets/TestPrefabInspector.cs:25)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

  1. Resolution Note (2019.2.X):

    This is by design. A Prefab asset cannot save references to Scene objects but it is valid for an Prefab instance to have a reference to other Scene objects. Note that the blue line in the Inspector stays even after Apply All has been executed (it is still marked as as an override since the value could not be saved to the Prefab).

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.