utopia-rise / godot-kotlin-jvm

Godot Kotlin JVM Module
MIT License
562 stars 38 forks source link

[Bugfix] Fix typed array registration #574

Closed chippmann closed 3 months ago

chippmann commented 5 months ago

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 commented 5 months ago

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

MartinHaeusler commented 5 months ago

@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: