Export non global custom resources. #77911
Open
+116
−53
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.
Fixes #73205
This PR adds support to export custom resources that are not available as global classes. As the issue points out: everything works fine with
class_name
but this functionality can still be very usefull for plugin development, as the use ofclass_name
should be avoided at all costs. Instead custom resources can be added viaadd_custom_type
. The Resources added in this way are not available as global names. Exporting them is only possible withpreload
.If the exported variable has a preloaded resource type the base type will be the path to the preloaded script. This PR adds various checks to load this script and work with it instead of failing, as the path is no valid global type.
Some notes on the bahaviour:
add_custom_type
it will get aScript
icon to distinguish it from other resources. Also the display name is determined by taking the file name and converting it to PascalCase. (Displaying the internal variable name would require changes at the GDScript level)add_custom_type
the icon and name from there will be usedThe PR unifies some duplicated validity checks in
_is_resource_valid
.TODO: