diff --git a/core/object/object.cpp b/core/object/object.cpp index bd4ff3d7b..77c0ad41a 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -2043,6 +2043,7 @@ void ObjectDB::remove_instance(Object *p_object) { rw_lock.write_unlock(); } + Object *ObjectDB::get_instance(ObjectID p_instance_id) { rw_lock.read_lock(); Object **obj = instances.getptr(p_instance_id); diff --git a/core/object/object.h b/core/object/object.h index 56213bc98..c7001aff9 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -856,6 +856,12 @@ public: typedef void (*DebugFunc)(Object *p_obj); static Object *get_instance(ObjectID p_instance_id); + + template + static T *get_instance(ObjectID p_instance_id) { + return Object::cast_to(get_instance(p_instance_id)); + } + static void debug_objects(DebugFunc p_func); static int get_object_count();