Editor: Avoid SetSceneCommnd
when importing file
#28339
Merged
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.
The issue: Importing 'object' scene(.json) currently performs a mix of 'appending object to default scene' and 'replacing default scene userData', this is problematic because objects in default scene may have scripts consuming userData of default scene, after importing one/multiple scenes(.json), the default scene's userData get replaced by the last imported one, e.g.:
A simple scene with a plane which has a script consuming
scene.userData
After importing scene1.json
After importing scene2.json
I.e. It is possible that when users PLAY the project, it'll throw because the original scene userData is gone.
This PR replaced
SetSceneCommand
byAddSceneCommand
, so each imported file is imported as a child of default scene, the graph for the above mentioned example would become:This way, the script of Plane can even access the imported scenes' userData via scene graph traversal
If replacing scene is desired, then I suggest implement
File>Open Project
instead because it has better semantic.Implemented, see #28351