In Godot 3.x, it was easy to add properties and property categories by overriding _get_property_list()
.
The following example, based on the docs, will show the test property in Godot 3.4.3 inspector when the following script is attached to a node:
tool
class_name PropTest extends Node
var test:int = 10 # We will store the value here
func _get(property):
if property == "my_property":
return test # One can implement custom getter logic here
func _set(property, value):
if property == "my_property":
test = value # One can implement custom setter logic here
return true
func _get_property_list():
var properties = []
# Same as "export(int) var my_property"
properties.append({
name = "my_property",
type = TYPE_INT
})
return properties
If I try the exact same code in Godot 4 (adding @ before tool), it doesn't update the inspector. The _get_property_list
method does get called, easily visible by adding a print call, but the property doesn't show in the inspector.
The latest docs has changed, and removed this exmaple. Is it no longer possible to do this with GDScript?