Is it possible to add custom description to properties from _get_property_list() to show it as a tooltip (instead of "No description")?
Not sure about godot 3, but you've tagged as godot 4 anyways, so looking at the docs:
https://docs.godotengine.org/en/latest/classes/class_object.html#class-object-method-get-property-list
the example included there:
@tool
extends Node2D
@export var holding_hammer = false:
set(value):
holding_hammer = value
notify_property_list_changed()
var hammer_type = 0
func _get_property_list():
# By default, `hammer_type` is not visible in the editor.
var property_usage = PROPERTY_USAGE_NO_EDITOR
if holding_hammer:
property_usage = PROPERTY_USAGE_DEFAULT
var properties = []
properties.append({
"name": "hammer_type",
"type": TYPE_INT,
"usage": property_usage, # See above assignment.
"hint": PROPERTY_HINT_ENUM,
"hint_string": "Wooden,Iron,Golden,Enchanted"
})
return properties
Shows that "hint_string": "string of text here"
could be used.
My doubt is about Godot 4 haha
What I want to change is the editor description of the property (tooltip). Instead of "No description.", I want to put a custom description text (example: "This is my property!").
hint_string is the field used to specify parameters of hint (like range, enum or filetype), not for descriptions.
In that case I know of no way of doing so. There was an addition made for having an editor description for nodes, but not for individual properties afaik.
I'm not sure I fully understand what you're talking about, but it seems to me that you're looking for a way to give the @export variables in editor descriptions.
If I understand correctly the solution is simple, just use the ## comment above the variables you want to document. It also works for node description.
## Node Description
extends Node2D
## This is my property!
@export var myProperty : bool
Note that the ## method works on all types of script not just in @tool one, so you don't need the
_get_property_list(), this of course only applies to descriptions. In addition Godot 4 sometimes does not take the description immediately, if you have any problems I suggest restarting the engine.
If you for some reason instead really want to use _get_property_list()
to add descriptions then I can't help.
Mancuso I think this is what OP was looking for because this is exactly what I was looking for, thank you!
Mancuso
That is what I need exactly🥰
© 2022 - 2024 — McMap. All rights reserved.