utopia-rise / godot-kotlin-jvm

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

Exported VariantArrays are missing type information in Godot Editor #573

Closed MartinHaeusler closed 3 months ago

MartinHaeusler commented 5 months ago

Exporting an array in GDScript like this:

@export var nodes: Array[Node3D]

... produces a typed array editor like this:

image

Exporting the corresponding array property in Kotlin:

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

... produces an untyped array editor like this:

image

Note that in the exported Kotlin property, the editor just says "Array (Size 2)" in the title, whereas in the GDScript case, it says "Array[Node 3D] (size 2)".

This issue is not merely cosmetical; in the editor resulting from kotlin code, the user can assign any resource type in the Godot editor, which will fail immediately with a type error at runtime.

@chippmann assumes that it has something to do with the way Godot 4 exports type hints for arrays.