godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

@export_label - read-only text object for the inspector #10201

Open yankscally opened 2 months ago

yankscally commented 2 months ago

Describe the project you are working on

many godot projects, custom nodes

Describe the problem or limitation you are having in your project

I want to write a large piece of read-only text in the inspector.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

similar to @icon this is for internal use only and mostly helps asset makers integrate custom nodes/resources well. It can be used to provide warnings in the inspector, explain properties, write notes, reminders.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Read-only text in the inspector:

@export_label("3D arrow class: can point towards the target, and use [code]is_centered[/code] to change the origin to the center of the arrow. There is a bug when yada yada... \n\n
This is in alpha dev. Please report any issues on github, or email me at yadayada@yapmaster.com")
@export_group("Visual")
@export_label("Here you can set the size and the material of the node. You can find some recommended materials in [code]res://addons/arrow_3d/materials[/code].")
@export var size = 1
...

the labels should be ordered with the other exports, in whichever category or group its in.

If this enhancement will not be used often, can it be worked around with a few lines of script?

yes. you can obviously use editor scripts to do this kind of thing, but I'd love this to be a part of the godot ecosystem as a standardised feature.

Is there a reason why this should be core and not an add-on in the asset library?

It would be really nice as an extra option for asset makers to be able to have text that asset users can read without a) using the tooltip or b) looking at the code / readme / docs

dalexeev commented 2 months ago

Do you mean something like this?

You can implement this using an inspector plugin.

As for out-of-the-box support, we could introduce a new property hint or usage flag, however note that this would be a fake property, something like categories/groups/subgroups. A lot of code both in the engine and in third-party plugins checks special usage flags to skip fake properties. Adding a new hint/flag may break the editor and third-party plugins.

yankscally commented 2 months ago

Do you mean something like this?

Not exactly like that. more similar to how text appears in the tooltip with (hopefully) tags like [code]. I put that in my example.

Yes - a fake property. Something that is editor-only, and displays non-editable text, and has no real functionality other than just to display text and help organise and beautify the nodes.

I wasn't aware fake properties work like that in the backend. I would have expected it to be more or less dormant.

Maybe there is a way to make a plugin to dynamically add these labels in code in a similar way.. I will have a go when the time comes

lostminds commented 2 months ago

this would be a fake property, something like categories/groups/subgroups

To avoid this issue with additional fake properties, perhaps this could be implemented by allowing longer descriptive texts to be added as an optional second parameter to export_group/subgroup/category instead of adding a new separate fake parameter?

So the above example would then be:

@export_group("Visual", "Here you can set the size and the material of the node. You can find some recommended materials in [code]res://addons/arrow_3d/materials[/code].")
@export var size = 1

The limitation would then of course be that you can only place these notes below such headings, and each note will have a heading.