godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.17k stars 21.2k forks source link

Minimum value `0.0001` in `hintString` for `Export` property with `PropertyHint.Range` shown as `0` in Editor #97617

Open ArtemkaKun opened 1 month ago

ArtemkaKun commented 1 month ago

Tested versions

System information

Godot v4.3.stable.mono unknown - Garuda Linux #1 SMP PREEMPT_DYNAMIC Fri, 20 Sep 2024 09:23:13 +0000 - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 6950 XT (RADV NAVI21) - AMD Ryzen 7 3800X 8-Core Processor (16 Threads)

Issue description

Export property in C# Resource class with hintString = "0.0001,1,or_greater" and PropertyHint.Range, when setup to the minimum allowed value (0.0001), displayed in Editor as 0, while still displaying correct value when hovering on the field.

Screenshot_1

When the minimum value in hintString is set to 0.001 - now it displayed correctly in the Editor.

Steps to reproduce

  1. Create a custom Resource class in C#.
  2. Add code [Export(PropertyHint.Range, "0.0001,1,or_greater")] public float MyValue { get; private set; }.
  3. Compile code.
  4. Create a new Resource asset and assign a newly created custom Resource class as a script to it.

Minimal reproduction project (MRP)

firearms.zip

timothyqiu commented 1 month ago

There's an editor setting default_float_step. It should be raised to 0.0001 in this case.

ArtemkaKun commented 1 month ago

This fixes the value view in Editor indeed, thank you for that.

Anyway, it still feels like a bug. First of all, why would step value influence a view of a value in the Editor? The leftmost position of a slider should represent the minimum possible value of the field, in my opinion.

Let me know what you think.

timothyqiu commented 1 month ago

You can also fix the problem by specifying the step in the hint string: "0.0001,1,0.0001,or_greater" if you don't want more precision than 0.0001.

The current mechanism of default step does cause some confusion. See also https://github.com/godotengine/godot-proposals/issues/3524

ArtemkaKun commented 1 month ago

I see, thanks for the info