Repository navigation
[prefab] Rework References behavior - #294
Merged
Merged
Conversation
…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>
…oadReference Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
EspeuteClement
marked this pull request as ready for review
October 6, 2026 12:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.