diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 3059ce445c2..d2af7879d27 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -32,9 +32,11 @@ #include "core/config/project_settings.h" #include "core/io/file_access.h" +#include "core/io/image_loader.h" #include "core/io/resource_loader.h" #include "editor/editor_node.h" #include "editor/editor_plugin.h" +#include "editor/editor_scale.h" #include "editor/editor_undo_redo_manager.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/resources/packed_scene.h" @@ -457,10 +459,10 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits, ct.name = p_type; ct.icon = p_icon; ct.script = p_script; + if (!custom_types.has(p_inherits)) { custom_types[p_inherits] = Vector(); } - custom_types[p_inherits].push_back(ct); } @@ -1028,8 +1030,57 @@ void EditorData::script_class_load_icon_paths() { } } +Ref EditorData::_load_script_icon(const String &p_path) const { + if (p_path.length()) { + Ref img = memnew(Image); + Error err = ImageLoader::load_image(p_path, img); + if (err == OK) { + img->resize(16 * EDSCALE, 16 * EDSCALE, Image::INTERPOLATE_LANCZOS); + return ImageTexture::create_from_image(img); + } + } + return nullptr; +} + +Ref EditorData::get_script_icon(const Ref