-
-
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
Calling duplicate(true)
on custom Resource returns empty Resource.
#33079
Comments
Confirming this is still happening in Godot |
I'm experiencing a likely overlapping issue with Godot 3.2.1 Mono where calling Here I am using a C#
|
I have this problem by calling
Here's a minimal working reproduction C# project |
I believe this may be the culprit behind what I have been running into as well (which I posted about here in the discord help channel). If you export a duplicated resource, it shows in the inspector as # export non-duplicated resource, which is the same instance everywhere
export(Resource) var normal = preload("path/to/resource")
# export duplicated resource
# (does the same thing if you store the preloaded resource into a constant and then just duplicate it here)
export(Resource) var duplicated = preload("path/to/resource").duplicate() |
Godot version:
3.1.1
OS/device including version:
Windows 10.0.18362
Issue description:
Resource.duplicate(true)
doesn't work for a custom Resource.Steps to reproduce:
duplicate(true)
).Minimal reproduction project:
The two tests pass for the first clone
r1
, but both tests fail for the deep duplicater2
.For
r2
,test1
throwsinvalid get index 'prop' (on base: 'Resource()')
andtest2
throwsinvalid get index 'prop' (on base: 'Nil')
.So it seems
duplicate(true)
just returns an empty resource.Hypothesis
I discovered that
r0
andr1
has the same script butr2
has a different script (print(r0.get_script())
). Printing outr0.get_property_list()
shows that theScript
property'susage
is7
(the default), which should cause it to be duplicated on aduplicate(true)
.Is this expected? Why would you want the script itself to be duplicated into a new instance? I was fully expecting it to just copy the data and retain the type/script of the original. I was not expecting it to essentially create a new type by duplicating the script resource.
I would suspect that the duplication of the script property is what causes the typing to fail in
test2
(discarding the object and passing Nil), but I would've expected it to still find the property intest1
. Would the duplicated script fail because theMyResource
class is already registered and just silently be thrown away, thus never initializing the object's properties? There are unfortunately no errors to give a clue to what happens here.The text was updated successfully, but these errors were encountered: