-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix recursive resource local to scene (array/dictionary properties on resources) #71578
Fix recursive resource local to scene (array/dictionary properties on resources) #71578
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
a77ad0a
to
bf10522
Compare
I would like to push this if possible. I'm building a game that relies heavily on resources to decouple systems and I have a lot of resources in arrays and dictionaries. With this merged in I can at least create a workaround by only having a Local to Scene resource hold my arrays of resources. Not 100% optimal, but it would let me do what I want to do. Also a little annoying to debug this issue when you first discover the Local to Scene checkbox. |
Can I push this again? It's really frustrating to debug for days until you find out that the error is because the resources inside an array are shared even if specified differently. Makes the use of Resources for anything more than surface-level data-objects needlessly difficult. |
bf10522
to
7980018
Compare
Rebased and applied review feedback, which cleaned up the code by a lot! :D |
Seems like it fixes #71243 too, not sure why you didn't link it. |
It doesn't fix the case where an array or a dictionary with sub-resources is exported directly on a Node (as opposed to being a property on a Resource). To fix it, we would need changes in the PackedScene loading code, which looks scary to me since it also needs to handle scene inheritance among other things. Here's what that issue's MRP prints with this PR. Note how the local scene is still null for array/dictionary entries of the node properties. Also note that the values for these three properties is not the same when compared to the initial state (lines marked with an arrow). Output Log
|
c628e01
to
f83a532
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes the issue and seems to work correctly. Not sure how to test for potential regressions, probably still needs checking from core team to spot if something is obviously wrong.
You should squash the commits into 1.
f83a532
to
47130f8
Compare
Should be good to merge now, but could be worth a rebase to make sure everything still builds fine. |
Any resource that contains other local to scene resources inside of arrays or dictionaries will now be duplicated and configured. The case where a scene's node has an exported array/dictionary property containing local to scene resources is NOT handled here.
47130f8
to
608b5d2
Compare
Thanks! |
Related to #71243
Fixes #71406
Fixes #85614
Any resource that contains arrays or dictionaries with local to scene resources will now be duplicated and configured correctly. This also includes built-in nodes, such as when marking a mesh's surface materials as local to scene.
A side effect of this change is that any array and dictionary property is now duplicated for local-to-scene instances.
What isn't handled in this PR is the case where a scene's node has an exported array/dictionary property containing local to scene resources. That code has a lot more special cases that I don't fully understand yet, but the solution would look largely similar.
NOTE: Using resources as dictionary keys does not work with the inspector (they get saved as
null
into the scene file), so this code branch was not tested.