summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Nations <willnationsdev@gmail.com>2019-02-06 17:53:24 -0600
committerWill Nations <willnationsdev@gmail.com>2019-03-17 00:04:15 -0500
commit2d106eb715239f42f3bf89652bab554af3c5a6a9 (patch)
tree8ed9189d7213ed243c17be1ee8724a8697056785
parentaff3dd36bad5cbffb5a995ed63eb67ad099e60e0 (diff)
Fix inherited icons for script classes
-rw-r--r--editor/editor_node.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6140412a32..e32593bbdf 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3350,12 +3350,30 @@ Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_f
if (ScriptServer::is_global_class(p_class)) {
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(p_class);
RES icon;
+
if (FileAccess::exists(icon_path)) {
icon = ResourceLoader::load(icon_path);
+ if (icon.is_valid())
+ return icon;
}
- if (!icon.is_valid()) {
- icon = gui_base->get_icon(ScriptServer::get_global_class_native_base(p_class), "EditorIcons");
+
+ Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(p_class), "Script");
+
+ while (script.is_valid()) {
+ String current_icon_path;
+ script->get_language()->get_global_class_name(script->get_path(), NULL, &current_icon_path);
+ if (FileAccess::exists(current_icon_path)) {
+ RES texture = ResourceLoader::load(current_icon_path);
+ if (texture.is_valid())
+ return texture;
+ }
+ script = script->get_base_script();
}
+
+ if (icon.is_null()) {
+ icon = gui_base->get_icon(ScriptServer::get_global_class_base(p_class), "EditorIcons");
+ }
+
return icon;
}