Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended class shows wrong icon #79979

Closed
abgenullt opened this issue Jul 28, 2023 · 2 comments · Fixed by #81336
Closed

Extended class shows wrong icon #79979

abgenullt opened this issue Jul 28, 2023 · 2 comments · Fixed by #81336

Comments

@abgenullt
Copy link

Godot version

4.1.1

System information

Linux Mint, Godot 4.1.1

Issue description

Hi,

I've extended my own class, which extends "Node2D".
Now, in the create node menu, the icon from the "Node" class is displayed instead of the icon from the extended "Node2d"-class.

Here is a screenshot to show how it looks:
Bildschirmfoto vom 2023-07-28 10-18-12

But after you create the node, the correct Icon is picked:

Bildschirmfoto vom 2023-07-28 10-20-07

Regards
abgenullt

Steps to reproduce

Extend from a custom class and check the icon in the menu.

Minimal reproduction project

InheritTest.zip

@dalexeev
Copy link
Member

The bug is reproducible in master, #79203 did not fix this. Maybe the reason is:

list=Array[Dictionary]([{
"base": &"Node2D",
"class": &"Base",
"icon": "",
"language": &"GDScript",
"path": "res://base.gd"
}, {
"base": &"Base",
"class": &"Extended",
"icon": "",
"language": &"GDScript",
"path": "res://extended.gd"
}])

As far as I understand, base should be a native class, even for inherited scripts.

@garychia
Copy link
Contributor

It looks like EditorNode::_get_class_or_script_icon only works when the inherited script has a builtin base type. It does not try to find the icon for a non-builtin base type.

godot/editor/editor_node.cpp

Lines 4293 to 4308 in 90f90cb

if (p_script.is_valid()) {
Ref<Texture2D> script_icon = ed.get_script_icon(p_script);
if (script_icon.is_valid()) {
return script_icon;
}
if (p_fallback_script_to_theme) {
// Look for the base type in the editor theme.
// This is only relevant for built-in classes.
String base_type;
p_script->get_language()->get_global_class_name(p_script->get_path(), &base_type);
if (gui_base && gui_base->has_theme_icon(base_type, SNAME("EditorIcons"))) {
return gui_base->get_theme_icon(base_type, SNAME("EditorIcons"));
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants