godot icon indicating copy to clipboard operation
godot copied to clipboard

Cannot edit exported property when using export_custom with Variant type hint

Open Gnumaru opened this issue 1 year ago • 2 comments

Tested versions

  • Reproducible in: v4.3.stable.official [77dcf97d8]

System information

Godot v4.3.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1060 6GB (NVIDIA; 31.0.15.3623) - AMD A10-7850K Radeon R7, 12 Compute Cores 4C+8G (4 Threads)

Issue description

When using the new @export_custom annotation for untyped properties, the inspector behavior is different if the user uses no type hints or the Variant type hint

image

The inspector only shows a usable field correctly when not using any type hint. It will show the type hint for the same type of the default value used as initializer for the property in the script.

But when using the Variant type hint, regardless of the property initializer value, the editor inspector will show a "<null>" label and the value won't be editable at all. I imagine the desired behavior would be for an usable inspector field to be show regardless when either not using type hints or explicitly using Variant as type hint.

As a side note, a similar thing happens with the data property of json resources, since the data property of a json resource is just a plain variant, it will always show a "" label regardless of the property contents. Please note I'm just pointing out an already existing similar behavior, not reporting a new issue.

image

Steps to reproduce

  1. in any project, create a new script
  2. put the code bellow there
@export_custom(0, '')
var exported_var_without_type_hint = 1.23
@export_custom(0, '')
var exported_var_using_variant_type_hint:Variant = 1.23

Minimal reproduction project (MRP)

ExportCustomWithVariantBug.zip

Other notes

Would this PR fix this?

Gnumaru avatar Aug 17 '24 12:08 Gnumaru