Implement Prefab workflow#776
Conversation
adriengivry
left a comment
There was a problem hiding this comment.
Looks really good!
Some feedback I have:
- In Unity, prefabs generally kind-of ignore the transformations on the topmost actor. With your feature, if I make a prefab from an actor, then duplicate this actor many time and place them in a level, reverting them to the original prefab will also move them back to the center of the level. We probably want the "Revert to prefab" to never revert the topmost actor's transform data. The only case the prefab's topmost actor's transform data would be used is when creating a new instance.
- It would be AWESOME if we could drag-and-drop any actor from the hierarchy to any folder in the asset browser to turn it into a prefab (using the actor's name as the prefab's name).
- When instancing a prefab, the prefab name should be used for the topmost actor, instead of the actor's name.
adriengivry
left a comment
There was a problem hiding this comment.
Works very well, I tested with a bunch of Cornell boxes!
A few issues I found:
- See comments I added in the code
- It is hard to know when looking at the hierarchy which source prefab an actor might come from. We could add a field to the actor's inspector, below "GUID" that would show an asset field of type prefab, similar to the "Target" field in asset properties, but that would be fully disabled.
- Reverting an actor to its source prefab overrides its name. In the case where you name your objects (e.g. Pillar 1, Pillar 2, Pillar 3, it will always go back to "Pillar" after reverting)
- Reverting an actor to its source prefab also move it in the hierarchy:
| Before Revert | After Revert |
|---|---|
![]() |
![]() |
There was a problem hiding this comment.
Note
Didn't look too hard in the code, since there are a few major issues that prevented further testing, and the code is likely gonna change.
Incorrect contextual actions
After creating a scene, adding a prefab, and reloading the scene, the contextual menu doesn't show anything else that "Save as prefab..." anymore, even after creating one.
[Regression] Broken contextual actions on loaded scenes
Whenever a scene is loaded (not new scene), contextual actions on any actor will be broken. e.g. cannot delete, duplicate, save as prefab, "Create..." menu will attach new actor to root instead...
Wrong GUID re-assignation
- Create a prefab with actor as children
- Drag-and-drop first children onto parent
- Notice A GUID is still correct
- Revert to prefab
- Notice A GUID is now different, and C now has A's GUID
adriengivry
left a comment
There was a problem hiding this comment.
Functionality-wise it seems to be nearly feature-complete. There are a few bugs and issues I found that are listed below.
Otherwise great work!
|
Seems like there are a few conflicts following the merging of your other PRs. |
# Conflicts: # Sources/OvEditor/include/OvEditor/Core/EditorActions.h # Sources/OvEditor/src/OvEditor/Panels/Hierarchy.cpp
It's sorted ! |

















Description
This PR delivers the prefab MVP workflow in the editor end-to-end: creating prefab assets from actors, instantiating prefabs, maintaining actor-to-prefab links ("source instance"), editing prefab instances (apply/revert), and propagating asset renames through scenes and prefabs.
Implemented:
.ovprefabfile type support in asset typing/parsing.Save as Prefab...in actor contextual menu.PrefabOperations).prefab_sourcesupport (API + serialization/deserialization).Create > From prefab...in actor creation menu (hierarchy + menu bar).Apply to PrefabandRevert to Prefabfor prefab-linked actors..ovprefabfiles..ovprefabfiles.Related Issue(s)
Fixes #25
Review Guidance
Please validate the prefab workflow in this order:
Save as Prefab....Create > From prefab...from hierarchy/menu bar.Apply to Prefab; verify.ovprefabcontent updates.Revert to Prefab; verify actor hierarchy is replaced correctly..ovscenefiles,.ovprefabfiles,Key files:
Sources/OvEditor/include/OvEditor/Utils/PrefabOperations.hSources/OvEditor/src/OvEditor/Utils/PrefabOperations.cppSources/OvEditor/include/OvEditor/Core/EditorActions.hSources/OvEditor/src/OvEditor/Core/EditorActions.cppSources/OvCore/include/OvCore/ECS/Actor.hSources/OvCore/src/OvCore/ECS/Actor.cppSources/OvEditor/src/OvEditor/Panels/Hierarchy.cppSources/OvEditor/src/OvEditor/Utils/ActorCreationMenu.cppSources/OvEditor/include/OvEditor/Panels/SceneView.hSources/OvEditor/src/OvEditor/Panels/SceneView.cppSources/OvTools/include/OvTools/Utils/PathParser.hSources/OvTools/src/OvTools/Utils/PathParser.cppSources/OvCore/src/OvCore/Helpers/GUIHelpers.cppSources/OvEditor/src/OvEditor/Core/EditorResources.cppSources/OvEditor/src/OvEditor/Core/Editor.cppResources/Editor/Textures/Prefab.pngScreenshots/GIFs
AI Usage Disclosure
Generated new code / Refactored code
Checklist