Skip to content

Commit 7f108cf

Browse files
committed
Merge pull request #88427 from CrayolaEater/fix-no-icons-on-remote-nodes
Fix Remote Nodes missing custom icons
2 parents e64662c + fb58ea6 commit 7f108cf

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

editor/debugger/editor_debugger_tree.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,14 @@ Variant EditorDebuggerTree::get_drag_data(const Point2 &p_point) {
277277
}
278278

279279
String path = selected->get_text(0);
280+
const int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor));
280281

281282
HBoxContainer *hb = memnew(HBoxContainer);
282283
TextureRect *tf = memnew(TextureRect);
283284
tf->set_texture(selected->get_icon(0));
284-
tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
285+
tf->set_custom_minimum_size(Size2(icon_size, icon_size));
286+
tf->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
287+
tf->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE);
285288
hb->add_child(tf);
286289
Label *label = memnew(Label(path));
287290
hb->add_child(label);

editor/editor_node.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4771,7 +4771,13 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons
47714771
// Look for the native base type in the editor theme. This is relevant for
47724772
// scripts extending other scripts and for built-in classes.
47734773
String script_class_name = p_script->get_language()->get_global_class_name(p_script->get_path());
4774-
String base_type = ScriptServer::get_global_class_native_base(script_class_name);
4774+
String base_type;
4775+
if (script_class_name.is_empty()) {
4776+
base_type = p_script->get_instance_base_type();
4777+
} else {
4778+
base_type = ScriptServer::get_global_class_native_base(script_class_name);
4779+
}
4780+
47754781
if (theme.is_valid() && theme->has_icon(base_type, EditorStringName(EditorIcons))) {
47764782
return theme->get_icon(base_type, EditorStringName(EditorIcons));
47774783
}
@@ -4836,6 +4842,8 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
48364842
Ref<Script> scr;
48374843
if (ScriptServer::is_global_class(p_class)) {
48384844
scr = EditorNode::get_editor_data().script_class_load_script(p_class);
4845+
} else if (ResourceLoader::exists(p_class)) { // If the script is not a class_name we check if the script resource exists.
4846+
scr = ResourceLoader::load(p_class);
48394847
}
48404848

48414849
return _get_class_or_script_icon(p_class, scr, p_fallback, true);

scene/debugger/scene_debugger.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,21 @@ SceneDebuggerTree::SceneDebuggerTree(Node *p_root) {
535535
}
536536
}
537537
}
538-
nodes.push_back(RemoteNode(count, n->get_name(), n->get_class(), n->get_instance_id(), n->get_scene_file_path(), view_flags));
538+
539+
String class_name;
540+
ScriptInstance *script_instance = n->get_script_instance();
541+
if (script_instance) {
542+
Ref<Script> script = script_instance->get_script();
543+
if (script.is_valid()) {
544+
class_name = script->get_global_name();
545+
546+
if (class_name.is_empty()) {
547+
// If there is no class_name in this script we just take the script path.
548+
class_name = script->get_path();
549+
}
550+
}
551+
}
552+
nodes.push_back(RemoteNode(count, n->get_name(), class_name.is_empty() ? n->get_class() : class_name, n->get_instance_id(), n->get_scene_file_path(), view_flags));
539553
}
540554
}
541555

0 commit comments

Comments
 (0)