migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
987 stars 55 forks source link

Feature Request: Shortcut for @Export(.nodeType, "Node") #454

Open univeous opened 2 months ago

univeous commented 2 months ago

For now, codes below's behavior is strange:

@Export
var node: Node?

I hope it works as in GDscript, allow me to pick a node in scene; instead it gives me a huge list of resources to create, which is totally nonsense:

image

The code from document

@Export(.nodeType, "Node")
 var node: Node?

works as I expected, but it's tedious.

I hope the bare

@Export
node Node?

works like @Export(.nodeType, "Node"), or add another annotation like @ExportNode that works as expected.

migueldeicaza commented 2 months ago

Interesting find.

I think that doing @Export var node: XXX? can work for built-in types, where we can probe for Xxx being of a built-in type [1], but would fail for things like Export var node: mySubNodeClass? because we would not know what mySubnodeClass is, but I think that those folks could use @Export (.nodeType, "Node") var node: mySubNodeClass?