Skip to content

[prefab] Rework References behavior - #294

Merged
EspeuteClement merged 46 commits into
masterfrom
reference-editor-rewrite
Oct 6, 2026
Merged

EspeuteClement merged 46 commits into
masterfrom
reference-editor-rewrite

Conversation

@EspeuteClement

Copy link
Copy Markdown
Contributor

This reworks how references are handled in the editor, and cleanup the overall reference architecture.

The main goal was to prevent undo/redo operations from creating new prefabs references, which would render closure on these references invalid and thus loosing edits. In that regard, Reference.refInstance was handled very poorly and this has changed.

Reference refInstance is now always the source of truth in the editor for what changes have been applied to the prefab. The refInstance persists across undo/redo edits, or if it need to be changed the undo/redo tracks that, which ensure we never loose changes across undo/redo operations.
The overrides field is now only used for save/load operation from disk, or if a load fails.
References that don't load in the editor have now their refInstance set to null and should behave more properly.
Due to this changes, reference old edit() function was removed, and now only edit2 persists which properly handle all the operation when changing the prefab source, changing edit mode, etc.
Now references with overrides need to keep their edit mode in Override mode. As a backward compatibility measure, all prefabs with overrides have their editMode set to override on load.
Clear override now should work properly and is correctly tracked by undo/redo operations.
This reworks also introduce a way for prefab to differentiate between save/load that are from disk and the ones that are done for temporary serialization in the editor, with the isTempSave/load functions. References need this to avoid saving on disk on each undo/redo step, and to only load their data from disk once in the editor when the tab is opened.
Changing a prefab in an editMode reference now update all the references in the editor to preview the changes.

Tests have been performed to check that no regression occurs in game code when loading data, and in the editor.

EspeuteClement and others added 30 commits October 6, 2026 12:37
…ce in the editor while still avoiding cycles
… the editor when save/loading temporary changes
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@EspeuteClement EspeuteClement changed the title Reference editor rewrite [prefab] Rework References behavior Oct 6, 2026
@EspeuteClement
EspeuteClement marked this pull request as ready for review October 6, 2026 12:34
@EspeuteClement
EspeuteClement merged commit 9d2bc29 into master Oct 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant