Skip to content

Add ability to create tooltip descriptions for dynamically exported properties#115182

Open
ryevdokimov wants to merge 1 commit intogodotengine:masterfrom
Open-Industry-Project:dynamic-description
Open

Add ability to create tooltip descriptions for dynamically exported properties#115182
ryevdokimov wants to merge 1 commit intogodotengine:masterfrom
Open-Industry-Project:dynamic-description

Conversation

@ryevdokimov
Copy link
Contributor

@ryevdokimov ryevdokimov commented Jan 20, 2026

Implements: godotengine/godot-proposals#8531

Example:

func _get_property_description(property: StringName) -> String:
	if property.begins_with("Light "):
		var index_str := property.trim_prefix("Light ")
		if index_str.is_valid_int():
			var index := index_str.to_int()
			if index == 1:
				return "Bottom segment of the stack light."
			elif index == segments:
				return "Top segment of the stack light."
			else:
				return "Middle segment %d of the stack light." % index
	return ""
2026-01-20.12-51-46.mp4

@ryevdokimov ryevdokimov requested a review from a team January 20, 2026 17:58
@ryevdokimov ryevdokimov requested review from a team as code owners January 20, 2026 17:58
@Calinou Calinou added this to the 4.x milestone Jan 21, 2026
@Repiteo Repiteo requested a review from a team as a code owner February 17, 2026 20:09
@Naros
Copy link
Contributor

Naros commented Feb 23, 2026

There should be a supplemental sibling PR that introduces this to Wrapped in godot-cpp.

@KoBeWi
Copy link
Member

KoBeWi commented Feb 23, 2026

Looks like this can replace the functionality added in #85868
And I guess it's related to godotengine/godot-proposals#13965 (makes it possible to implement it, but without docs)

However using it in the engine requires binding a method, which is not ideal.

Copy link
Contributor

@Zehir Zehir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested (and look at the code) the changes, and it's working as expected. However, I would make some changes;

Documentation

Maybe it's worth mentioning in the documentation that the description supports BBCode ?
image

func _get_property_description(property: StringName) -> String:
	return "Sample description of [b]property[/b] '%s'" % property

Extend usage for category, group and subgroup

Also I was not able to add a description to property with usage PROPERTY_USAGE_CATEGORY, PROPERTY_USAGE_GROUP and PROPERTY_USAGE_SUBGROUP

	properties.append({
		"name": "Numbers",
		"type": TYPE_NIL,
		"hint_string": "number_",
		"usage": PROPERTY_USAGE_GROUP
	})
Image Image

But I was able to add one for PROPERTY_HINT_GROUP_ENABLE

Image

Context

Full Test Node script
@tool
extends Node
class_name TestNode

@export var number_count = 3:
	set(nc):
		number_count = nc
		numbers.resize(number_count)
		notify_property_list_changed()

var numbers = PackedInt32Array([0, 0, 0])

func _get_property_list():
	var properties: Array[Dictionary] = []

	properties.append({
		"name": "Numbers",
		"type": TYPE_NIL,
		"hint_string": "number_",
		"usage": PROPERTY_USAGE_GROUP
	})

	for i in range(number_count):
		properties.append({
			"name": "number_%d" % i,
			"type": TYPE_INT,
			"hint": PROPERTY_HINT_ENUM,
			"hint_string": "ZERO,ONE,TWO,THREE,FOUR,FIVE",
		})

	return properties

func _get(property):
	if property.begins_with("number_"):
		var index = property.get_slice("_", 1).to_int()
		return numbers[index]
	return null

func _set(property, value):
	if property.begins_with("number_"):
		var index = property.get_slice("_", 1).to_int()
		numbers[index] = value
		return true
	return false


func _get_property_description(property: StringName) -> String:
	return "Description for '%s'" % property

@ryevdokimov ryevdokimov force-pushed the dynamic-description branch from 559600e to 793dd90 Compare March 7, 2026 22:09
@ryevdokimov
Copy link
Contributor Author

Suggestions applied.

image

@ryevdokimov ryevdokimov requested a review from Zehir March 7, 2026 22:12
Copy link
Contributor

@Zehir Zehir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the PR and it's working correctly, I was not able to break it in some wierd ways
The code looks good to me.

About groups this does works for ;

  • PROPERTY_USAGE_GROUP
  • PROPERTY_USAGE_SUBGROUP

But not for PROPERTY_USAGE_CATEGORY but I don't know if it's worth adding too ?

Image

The _get_property_warning method don't display the warning for the group but it's currently been reworked in the PR #90049 and so I guess we can ignore it for this PR.

Next step team review I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants