![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Sniperchang |
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?
i would also like to know the answer to this question, as my properties are no longer exporting in the most frustrating way after attempting to port
WolframR | 2022-07-04 21:21
I have the same issue. I now filed a bug, because it seems that there are some issue in Godot 4 (see here and here)
st_phan | 2023-04-05 08:43
A helpful person mentioned that you have to reload the scene in order for it to work!
st_phan | 2023-04-05 09:32