Skip to content
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

Export non global custom resources. #77911

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HolonProduction
Copy link
Contributor

@HolonProduction HolonProduction commented Jun 6, 2023

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 of class_name should be avoided at all costs. Instead custom resources can be added via add_custom_type. The Resources added in this way are not available as global names. Exporting them is only possible with preload.

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:

  • if the exported type is not added via add_custom_type it will get a Script 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)
  • if the exported type is identical to a script added via add_custom_type the icon and name from there will be used
  • if the exported type is preloaded script, the editor will loop through all global and custom types and will check whether they inherit from this script and display them in the create dialogue if so
  • drag and drop as well as loading will accept resources which inherit the exported script, even if they are not global or added as custom types
  • quick loading does not work

The PR unifies some duplicated validity checks in _is_resource_valid.

TODO:

@YuriSizov
Copy link
Contributor

YuriSizov commented Jun 26, 2023

This probably addresses #70991 as well, or at least it should ideally 🙃

@HolonProduction
Copy link
Contributor Author

This probably addresses #70991 as well, or at least it should ideally 🙃

See comment there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot assign a custom resource when the class is loaded with preload().
2 participants