-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Resource.duplicate(true) does not duplicate subresources in arrays #82348
Comments
Interesting. I am quite concerned that AnimationLibrary is a resource which holds Animation sub-resources in a Dictionary. Could it have the same issue, or does it only affect arrays. It would be interesting to test duplicating an AnimationLibrary with Animations inside and see if it possibly has the same issue. |
Taking a look at the array and dictionary code, it looks like the core issue is that Array::duplicate calls Array::recursive_duplicate, which in turns calls recursive_duplicate for the object. Seems like that's implemented in the variant_setget.cpp file (no clue why it's there). There, we can see that the object duplication does not occur since it 'breaks stuff'. (The same issue seems to exist for dictionaries as well) |
Is this related to #74918 ? |
Thanks for the report! Consolidating in #74918. |
Godot version
v4.2.dev.custom_build [2048fe5]
System information
Godot v4.2.dev (2048fe5) - Gentoo 2.14 - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 6600 (RADV NAVI23) () - AMD Ryzen 5 5600 6-Core Processor (12 Threads)
Issue description
When duplicating
Resource
s withduplicate()
, a newResource
with its properties copied over is returned. Though, if there are otherResource
s as properties, only the references to them are copied, not their contents. Unless the argumenttrue
is given to the function, in which case theResource
s contained in the new are unique, not referencing the same ones as the original.This statement is not true when those
Resource
s are contained within an array. Here are screenshots comparing two resources duplicated withduplicate(true)
at runtime.Note: Notice how the
subresource
s are different, duplicated as they should be, but not the elements ofarray_of_subresources
.Original resource:
Duplicated resource:
Steps to reproduce
duplicate(true)
, and compare the two resources from the arrays:Minimal reproduction project
godot.zip
The text was updated successfully, but these errors were encountered: