0 votes

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?

Godot version 4.0.alpha
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.