How to get an Array of all const’s of an object/class?
According to the documentation for Object, get_property_list() should return an array of properties. And get() is supposed to work for a property, and is returning the expected result if passed the name of a const. But get_property_list() is lacking those same consts.
Any idea how to get an Array of ['a','b','c'] from this object?
class MyClass:
const a = '1'
const b = '2'
const c = '3'
func _ready() -> void:
var obj := MyClass.new()
var l:= obj.get_property_list() # returns dicts, but we just need the names.
var l2 := []
for i in l:
l2.append(i['name'])
print(l2) # ["RefCounted", "script", "Built-in script"]
print(obj.get('a')) # 1
# ????? print ['a','b','c']
if a in obj: array.append['a']
get_property_list() is for mostly debugging things and works during debug remote, and not suits to filter things.
so its enough to check if property exist just by if &'property_name' in Object: