I want to collect classes, that are inherited from a specified class. Each derived class have static method like get_name
. So I want my collection to be a dictionary with key equal to get_name
-s return value and value should be a class name (or even a GDScript
object, if it is possible). And I want to do this without objects instancing.
Here is a code example:
var _class_collection: Dictionary = {}
var _class_name_list = ClassDB.get_inheriters_from_class("BaseClass")
for _class_name in _class_name_list:
# The next function doesn`t exist, but it is the thing that I want to achieve
var _name = ClassDB.call_static_method(_class_name, "get_name")
_class_collection[_name] = _class_name
As far as I know, static method is like a global method, but in class namespace. So it should be possible to call method without object instancing.
Does anybody know if it is possible and how to achieve this in Godot?