godot-kotlin-jvm icon indicating copy to clipboard operation
godot-kotlin-jvm copied to clipboard

[Bugfix] Fix typed array registration

Open chippmann opened this issue 1 year ago • 2 comments

Fixes #573

With godot 4 the hint string for the inspector changed it's format and now also Node and Resource based classes are allowed for Array's. Our implementation now covers those cases as well.

For reference, the code which handles this in the inspector can be found here: https://github.com/godotengine/godot/blob/36e943b6b20cb7a8a89bc30489c4a81c3e149d74/editor/editor_properties_array_dict.cpp#L616-L635

And the GDScript parser handles this here: https://github.com/godotengine/godot/blob/36e943b6b20cb7a8a89bc30489c4a81c3e149d74/modules/gdscript/gdscript_parser.cpp#L4077-L4170

Custom classes are also supported now:

chippmann avatar Feb 08 '24 09:02 chippmann

@MartinHaeusler If you could test your cases here as well, I'd be very grateful :-)

chippmann avatar Feb 08 '24 09:02 chippmann

@chippmann my use case was simply:

@Export
@RegisterProperty
var nodes: VariantArray<Node3D>? = null

It looks to me like your test cases went far beyond that, which is cool! I was able to "fix" my case with the current release codebase by manually assigning NodePath resources to the array entries in the editor, and then assigning the actual nodes to the node paths. It works, but was very clunky and it had the issue that I could add arbitrary resources to the array. Your screenshots already show that this is no longer the case, which is great :+1:

MartinHaeusler avatar Feb 08 '24 10:02 MartinHaeusler