Prefab lost all references on the scene when I update it

Hello there,

If you add a predab in a scene then your will set property from the scene and when you save the prefab all properties from the scene will be cleared.

Example:
image

image

it’s obvious. Prefab is not part of scene, it’s asset which can’t hold a ref. on scene.

It’s weird because the updated prefab stays on the scene like the references.
I have to compare with Unity because In Unity you can update a prefab on the Scene and keep all references added on the Prefab.

agreed, in CC there are a lot of ‘magic behaviours’

Large GIF (958x392)

MAGIC!!! lol

When you update from the prefab editor and not directly from the scene the references do not break.
So, this is clearly a bug and not an intended behavior.

I made an issue on git but it was never answered: Prefab save from instance breaks custom component links external to prefab · Issue #12918 · cocos/cocos-engine · GitHub

2 Likes

The prefab can only save its internal link, if the linked objects are not in the prefab, it can be dragged and dropped in the scene, this drag and drop only saves the link when in the scene, but when this prefab is opened, the link will not exist.
When you click tick, it means update all prefab properties because it updates prefab independently => lost link

Yes, that is the logic behind it, but it is nonetheless a bug, and should be recognized as such.

It basically prevents you to use the whole save prefab from scene feature in a lot of cases.

It should be easy to code that the external references are not saved in the prefab asset but are not broken in the prefab instance.

I tried looking in the source code, but it doesn’t seem to be in the open source part.

In Unity: Screen capture - cacbdf2cdb699b10d318ba3b249bd7c9 - Gyazo

Unity does not clear property fields of external GameObject when we update the prefab.

1 Like