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

Dont allow exporting Nodes from Custom Resources (par with gdscript) #654

Open
jrockett6 opened this issue Apr 1, 2024 · 4 comments
Open
Labels
bug c: register Register classes, functions and other symbols to GDScript

Comments

@jrockett6
Copy link
Contributor

jrockett6 commented Apr 1, 2024

Par with gdscript per godotengine/godot#82843

It would be nice if this could be allowed for built-in resources. I left a comment here godotengine/godot#80538

@lilizoey lilizoey added bug c: register Register classes, functions and other symbols to GDScript labels Apr 1, 2024
@jrockett6 jrockett6 changed the title Dont allow (or error) when exporting Nodes from Custom Resources (par with gdscript) Dont allow exporting Nodes from Custom Resources (par with gdscript) Apr 1, 2024
@jrockett6
Copy link
Contributor Author

Oh and maybe I should mention that the current behavior is that it allows you to select a node from the scene to use in the exported field like normal, but instead of adding the node to the scene as a node path (which would be nice for built in resources) it creates an a duplicate of that node that ends up being an orphaned object.

@Bromeon
Copy link
Member

Bromeon commented Apr 1, 2024

What exactly needs changing in gdext?

@jrockett6
Copy link
Contributor Author

jrockett6 commented Apr 1, 2024

Im not sure how it would want to be shown - like as a compile error or a warning or something else when using the #[export] attribute.

The gdscript behavior is that when you try to

extends Resource

@export var x: Node

you are given an error like:
Screen Shot 2024-04-01 at 10 16 59 AM

Currently in Rust (or before this was fixed in gdscript) this leads to some unsuspected user bugs when it lets you set nodes in the editor, but then the nodes are duplicated orphaned objects instead of references as expected.

But I am still curious if this behavior should be allowed (but fixed in Godot - to use node paths and not duplicate the node) for built-in resources, which I asked here. In which case the solution for disallowing this in #[export] attribute would probably not be a viable solution, and I think things would have to be fixed on the Godot side because at that point the behavior is dependent on what the .tscn file looks like.

So to answer the question - maybe the solution is to wait until that question is answered, and if the behavior is to remain the same then add some sort of checks to #[export]?

@lilizoey
Copy link
Member

lilizoey commented Apr 1, 2024

here's one way we could disallow it that lives entirely in the type system
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=834bb7d13150904d471eef57e73d1b66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: register Register classes, functions and other symbols to GDScript
Projects
None yet
Development

No branches or pull requests

3 participants