diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index 258b01542e2..4cbc2e1df6e 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -245,6 +245,7 @@ void GDExtension::_register_extension_class(GDExtensionClassLibraryPtr p_library p_extension_funcs->is_abstract, // GDExtensionBool is_abstract; true, // GDExtensionBool is_exposed; false, // GDExtensionBool is_runtime; + nullptr, // GDExtensionConstStringPtr icon_path; p_extension_funcs->set_func, // GDExtensionClassSet set_func; p_extension_funcs->get_func, // GDExtensionClassGet get_func; p_extension_funcs->get_property_list_func, // GDExtensionClassGetPropertyList get_property_list_func; @@ -280,6 +281,7 @@ void GDExtension::_register_extension_class2(GDExtensionClassLibraryPtr p_librar p_extension_funcs->is_abstract, // GDExtensionBool is_abstract; p_extension_funcs->is_exposed, // GDExtensionBool is_exposed; false, // GDExtensionBool is_runtime; + nullptr, // GDExtensionConstStringPtr icon_path; p_extension_funcs->set_func, // GDExtensionClassSet set_func; p_extension_funcs->get_func, // GDExtensionClassGet get_func; p_extension_funcs->get_property_list_func, // GDExtensionClassGetPropertyList get_property_list_func; @@ -315,6 +317,7 @@ void GDExtension::_register_extension_class3(GDExtensionClassLibraryPtr p_librar p_extension_funcs->is_abstract, // GDExtensionBool is_abstract; p_extension_funcs->is_exposed, // GDExtensionBool is_exposed; p_extension_funcs->is_runtime, // GDExtensionBool is_runtime; + nullptr, // GDExtensionConstStringPtr icon_path; p_extension_funcs->set_func, // GDExtensionClassSet set_func; p_extension_funcs->get_func, // GDExtensionClassGet get_func; p_extension_funcs->get_property_list_func, // GDExtensionClassGetPropertyList get_property_list_func; @@ -456,6 +459,13 @@ void GDExtension::_register_extension_class_internal(GDExtensionClassLibraryPtr #endif ClassDB::register_extension_class(&extension->gdextension); + + if (p_extension_funcs->icon_path != nullptr) { + const String icon_path = *reinterpret_cast(p_extension_funcs->icon_path); + if (!icon_path.is_empty()) { + self->class_icon_paths[class_name] = icon_path; + } + } } void GDExtension::_register_extension_class_method(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info) { diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h index b401acef829..8017733e365 100644 --- a/core/extension/gdextension_interface.h +++ b/core/extension/gdextension_interface.h @@ -368,6 +368,7 @@ typedef struct { GDExtensionBool is_abstract; GDExtensionBool is_exposed; GDExtensionBool is_runtime; + GDExtensionConstStringPtr icon_path; GDExtensionClassSet set_func; GDExtensionClassGet get_func; GDExtensionClassGetPropertyList get_property_list_func; diff --git a/core/extension/gdextension_manager.cpp b/core/extension/gdextension_manager.cpp index 0dc13cf3759..25f99ca122f 100644 --- a/core/extension/gdextension_manager.cpp +++ b/core/extension/gdextension_manager.cpp @@ -210,6 +210,12 @@ void GDExtensionManager::initialize_extensions(GDExtension::InitializationLevel ERR_FAIL_COND(int32_t(p_level) - 1 != level); for (KeyValue> &E : gdextension_map) { E.value->initialize_library(p_level); + + if (p_level == GDExtension::INITIALIZATION_LEVEL_EDITOR) { + for (const KeyValue &kv : E.value->class_icon_paths) { + gdextension_class_icon_paths[kv.key] = kv.value; + } + } } level = p_level; }