godotengine / godot

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

Metadata names are mangled in inspector. #82938

Open SpaceAceMonkey opened 11 months ago

SpaceAceMonkey commented 11 months ago

Godot version

4.1.1 Mono stable

System information

Ubuntu 22.04, Godot 4.1.1 Mono stable

Issue description

Godot changes metadata key names so they follow specific capitalization and spacing rules in the inspector, but does not enforce those rules in the actual object metadata. This means the metadata names in the inspector can be very different from the metadata names on the actual objects. This will cause confusion on projects with multiple devs, large projects, and any project the dev is coming back to after taking some time off.

Not only do the actual metadata names not match Spaced Out Pascal Case, they can't match Spaced Out Pascal Case. If you try to create a metadata key such as This Key Right Here in the inspector, it will display the error message Metadata name must be a valid identifier and disable the Add button.

Steps to reproduce

Create any type of object and click "Add Metadata" in the inspector.

Create a few metadata key/value pairs.

type: String = My Type another_key: bool = true

These will show in the inspector as Type and Another Key.

Try to fetch the metadata:

your_object.get_meta("Type", "Nope") Nope

your_object.get_meta("Another Key", "Nope") Nope

your_object.get_meta("type", "Nope") My Type

your_object.get_meta("Another Key", "Nope") true

Minimal reproduction project

metanope.tar.gz

Calinou commented 11 months ago

This is expected, and is done for consistency with editor properties themselves. When using Godot, it's expected that users are aware of this behavior when setting properties from code (hover a property's name in the inspector to see its actual name you should read/assign from scripts).

You can disable the automatic capitalization behavior in the Editor Settings.

One area of improvement is to change Property: metadata/<metadata_name> in the EditorHelpBit that appears when hovering a metadata property in the inspector to Metadata: <metadata_name> instead. Edit: Done in https://github.com/godotengine/godot/pull/82940.

SpaceAceMonkey commented 11 months ago

This is expected, and is done for consistency with editor properties themselves.

Is there any way this could be considered beneficial to the user? Is it important to force these to be consistent with other editor properties when they are more like Dictionary keys specified by the user? The user isn't even allowed to make them match what will be displayed in the inspector unless they use keys that consist of exactly one word beginning with exactly one capital letter. This seems like a needless frustration. What problem is this behavior solving?

If this behavior was turned off by default, do you think the number of people who would go into the editor settings and turn on the option to make the editor display incorrect metadata key names would be greater than zero? It may be that I am missing something obvious, here.

Speaking of which, I can't find this option. I've tried searching for "meta," "capital," "case," and "property." The only thing I found was "Default Property Name Style" which had no effect on the metadata key names.

Mickeon commented 11 months ago

The capitalization behavior feels silly. They're metadata. It's data that designers and the likes of them ideally shouldn't look too much into. They do not have to look pretty, and instead it would be more favourable if they look accurate.

Johnrobmiller commented 9 months ago

This is expected, and is done for consistency with editor properties themselves. When using Godot, it's expected that users are aware of this behavior when setting properties from code (hover a property's name in the inspector to see its actual name you should read/assign from scripts).

You can disable the automatic capitalization behavior in the Editor Settings.

One area of improvement is to change Property: metadata/<metadata_name> in the EditorHelpBit that appears when hovering a metadata property in the inspector to Metadata: <metadata_name> instead. Edit: Done in #82940.

Be careful when saying things like "This is expected". For whom is it expected for? Is it expected for the developer, who implemented the solution and has the correct mental model of the system's behavior? Or, it is expected for the user, who was never provided with an interface with good enough usability for them to learn the correct mental model?

It is expected for the former, but not the latter. Therefore, it is not really correct to say things like "This is expected". Oftentimes, when developers say things like "This is expected", that can be translated by a UX designer as "usability could be improved here."

Apologies for putting you on the spot, I know it's common to say "This is expected" so it's not fair to pick you out like that.

gringer commented 3 months ago

This bug has bitten me as well. Please do one of the following:

It doesn't make sense for me to add case insensitivity modifications to my code because I can't remember or work out if I initially typed the key in upper-case or lower-case.