When adding a custom resource as an Array type for the # @@resource_table, I get the following error:
Cannot get class 'CustomResource'.res://addons/inspector_extender/attributes/table.gd:158 - Invalid call. Nonexistent function 'get_property_list' in base 'Nil'.
Using the following code:
# @@resource_table() @export var data : Array[CustomResource]
This is because of an inconsistency in the ClassDB class.
table.gd performs the following check:
if ClassDB.can_instantiate(array_class_name):row_resource = ClassDB.instantiate(array_class_name)
From this Godot issue:
https://github.com/godotengine/godot/issues/71744
can_instantiate returns "true" when I call it on a custom class, which is very misleading as instantiate later returns null.
Solution
The custom creation script shouldn't be called in the else clause, but if the previous call returned null:
if ClassDB.can_instantiate(array_class_name):row_resource = ClassDB.instantiate(array_class_name)if row_resource == null:row_resource = _instantiate_custom_class(array_class_name)
When adding a custom resource as an Array type for the # @@resource_table, I get the following error:
Cannot get class 'CustomResource'.
res://addons/inspector_extender/attributes/table.gd:158 - Invalid call. Nonexistent function 'get_property_list' in base 'Nil'.
Using the following code:# @@resource_table() @export var data : Array[CustomResource]
This is because of an inconsistency in the ClassDB class. table.gd performs the following check:
if ClassDB.can_instantiate(array_class_name):
row_resource = ClassDB.instantiate(array_class_name)
From this Godot issue: https://github.com/godotengine/godot/issues/71744 can_instantiate returns "true" when I call it on a custom class, which is very misleading as instantiate later returns null.
Solution The custom creation script shouldn't be called in the else clause, but if the previous call returned null:
if ClassDB.can_instantiate(array_class_name):
row_resource = ClassDB.instantiate(array_class_name)
if row_resource == null:
row_resource = _instantiate_custom_class(array_class_name)