-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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 using Resource objects as keys in the tres
format
#64812
Conversation
If your PR fixes an issue, please link it like this:
I also highly recommend checking how other PRs are formatted. 😃 Once your PR is ready for review again, squash your commits. PRs should be composed of a single commit, with no merge commits. |
2ee7468
to
7cb10c8
Compare
I just force-pushed the commits before merging the master branch, don't know if it's OK. 😃 |
fix issue 57506
: Saving the resource as tres
format will cause the resource as the key to be null
because the key is not cached.tres
format will cause the resource as the key to be null
because the key is not cached.
There's an issue with the GitHub workflows on this PR (not your fault), just testing a close and reopen to see if that solves it. |
Any news on this? Would be nice to be able to use custom resources as keys in dictionaries and have them serialize properly. |
This looks good, but it needs to be fixed to pass CI |
7cb10c8
to
ad8bf25
Compare
Force pushed a rebase which should fix CI. |
ad8bf25
to
d3612e0
Compare
tres
format will cause the resource as the key to be null
because the key is not cached.tres
format
Thanks! And congrats for your first merged Godot contribution 🎉 |
Version of Godot based on:
v4.0.alpha.custom_build [14f8a54a3]
The changed files are as follows:
godot\scene\resources\resource_format_text.cpp
The problem solved is as follows:
The minimal case that can be tested is as follows:
https://github.com/godotengine/godot/files/7977119/ResourcesTest.zip
Precautions:
ResourceSaver.save
: now thefirst
parameter isresource
and thesecond
ispath
, the code in this case is just the opposite.Roughly the process of solving the problem:
After many tests, the execution process of saving resources is roughly as follows:
And the member variables in the script_instance of the incoming p_resource all exist, that is to say, they are the same in terms of parameters.
But I noticed that after the execution of
in
The value of
load_steps
is significantly different(compared toResourceFormatSaverBinaryInstance
), andsaved_resources
does not save the resource of the key-value pair with resource as the key. ButResourceFormatSaverBinaryInstance
doesn't have this problem.So I checked
And found that the key is also cached in the case where p_variant is Variant::DICTIONARY.
So I guess the problem with
ResourceFormatSaverTextInstance
is that it doesn't cache the key.