@@ -5266,7 +5266,7 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na
52665266 }
52675267}
52685268
5269- Ref<Texture2D> EditorNode::_get_class_or_script_icon (const String &p_class, const String &p_script_path, const String &p_fallback, bool p_fallback_script_to_theme) {
5269+ Ref<Texture2D> EditorNode::_get_class_or_script_icon (const String &p_class, const String &p_script_path, const String &p_fallback, bool p_fallback_script_to_theme, bool p_skip_fallback_virtual ) {
52705270 ERR_FAIL_COND_V_MSG (p_class.is_empty (), nullptr , " Class name cannot be empty." );
52715271 EditorData &ed = EditorNode::get_editor_data ();
52725272
@@ -5289,8 +5289,9 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons
52895289 base_type = scr->get_instance_base_type ();
52905290 }
52915291 }
5292- if (theme.is_valid () && theme->has_icon (base_type, EditorStringName (EditorIcons))) {
5293- return theme->get_icon (base_type, EditorStringName (EditorIcons));
5292+ if (theme.is_valid ()) {
5293+ bool instantiable = !ClassDB::is_virtual (p_class) && ClassDB::can_instantiate (p_class);
5294+ return _get_class_or_script_icon (base_type, " " , " " , false , p_skip_fallback_virtual || instantiable);
52945295 }
52955296 }
52965297 }
@@ -5324,11 +5325,20 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons
53245325
53255326 // If the fallback is empty or wasn't found, use the default fallback.
53265327 if (ClassDB::class_exists (p_class)) {
5327- bool instantiable = !ClassDB::is_virtual (p_class) && ClassDB::can_instantiate (p_class);
5328- if (ClassDB::is_parent_class (p_class, SNAME (" Node" ))) {
5329- return theme->get_icon (instantiable ? " Node" : " NodeDisabled" , EditorStringName (EditorIcons));
5330- } else {
5331- return theme->get_icon (instantiable ? " Object" : " ObjectDisabled" , EditorStringName (EditorIcons));
5328+ if (!p_skip_fallback_virtual) {
5329+ bool instantiable = !ClassDB::is_virtual (p_class) && ClassDB::can_instantiate (p_class);
5330+ if (!instantiable) {
5331+ if (ClassDB::is_parent_class (p_class, SNAME (" Node" ))) {
5332+ return theme->get_icon (" NodeDisabled" , EditorStringName (EditorIcons));
5333+ } else {
5334+ return theme->get_icon (" ObjectDisabled" , EditorStringName (EditorIcons));
5335+ }
5336+ }
5337+ }
5338+ StringName parent = ClassDB::get_parent_class_nocheck (p_class);
5339+ if (parent) {
5340+ // Skip virtual class if `p_skip_fallback_virtual` is true or `p_class` is instantiable.
5341+ return _get_class_or_script_icon (parent, " " , " " , false , true );
53325342 }
53335343 }
53345344 }
0 commit comments