-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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 support for gdscript resource types #26162
Conversation
aca178b
to
4e62432
Compare
Note that if the script you export extends a node type, it will leak unless you add it to the tree in code or free it. |
@Zylann I believe that bit it worth adding to the docs? |
@Zylann if I'm understanding correctly, I think this shouldn't be an issue because the type resolution step should ensure that the exported type derives from Resource, either directly or through other global script classes. |
2d12065
to
dc87d74
Compare
This is wonderful |
dc87d74
to
450b34c
Compare
Much like how script defined global classes can be created from the "New Resource..." button in the FileSystem panel, this allows the creation of script defined resources to be embedded.
450b34c
to
2b7b64f
Compare
This has broken and conflicts with other changes. I'm going to wait till 3.1 is branched and I'll fix it up for review in to 3.2 |
This needs a rebase (and a review, ping @vnen @bojidar-bg). |
Solves same issue as #22660? |
Still needs a rebase. Should be compared with #22660 which seems to address a similar feature, to see which implementation is the most interesting (if they do overlap). CC @willnationsdev |
@akien-mga Mine stopped working quite a ways back and I never went back to fix it (and it was buggy to begin with), so I'd opt to go for this solution over the one I wrote. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vixelz Out of curiosity, does the implementation work with resources declared as constants too and/or arrays of custom resources?
@@ -2754,6 +2770,20 @@ void EditorPropertyResource::set_use_sub_inspector(bool p_enable) { | |||
use_sub_inspector = p_enable; | |||
} | |||
|
|||
String EditorPropertyResource::_get_file_script_name_or_default(const RES &p_resource) const { | |||
Ref<Script> rscript = p_resource->get_script(); | |||
if (rscript != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency/clarity, I would recommend making this be if (rscript.is_valid())
or something.
Ohh I can’t wait for this to be rebased and merged! Please let it be soon! ;) |
I've encountered an error while testing the branch. If I try to type an exported var, I get the error:
This will appear on any type of export, whether they're custom, native, or even primitive. # None of those work
export(Texture) var texture: Texture
export(int) var index: int
export(String) var text := "Hello"
export(Array, AudioStream) var streams: Array The error can be avoided by not typing exported variables. This is not convenient though, as it prevents auto-completion, safe lines… Well, everything that comes with typed variables. I see the branch needs to be rebased, so maybe this has already been fixed on master. I hope this feature will soon be included in a release, because it might become indispensable for plugins! :) |
We discussed this briefly on IRC with @vnen and @bojidar-bg, some comments:
As we're in feature freeze for 3.2 and this PR is not merge-ready for now, moving to the 4.0 milestone. It's a good feature proposal though, but some updates and a thorough review are needed. |
@@ -582,6 +582,8 @@ class EditorPropertyResource : public EditorProperty { | |||
void _button_input(const Ref<InputEvent> &p_event); | |||
void _open_editor_pressed(); | |||
void _fold_other_editors(Object *p_self); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just clean whitespaces in empty line to pass clang-format in Travis
@aaronfranke I'm still interested and happy to finish the work if @vixelz does not. |
For what its worth, I am very much interested in this feature - working on a space station economy simulator and this would make the data-driven exports soooo much cleaner. |
@aaronfranke @rcorre I'd thought that my PR was further along in this as it is derived from vixelz's initial work. I am planning to rebase and fixup that PR too. #32018 |
This PR has not received any new commits for over a year and is abandoned by the author, closing. This PR can be salvaged, but it seems that @willnationsdev is already doing so. |
Allow GDScript export statements to export global class types.