Procházet zdrojové kódy

Merge pull request #75938 from YuriSizov/editor-no-spammy-icons

Prevent errors in the Inspector when looking for script icons
Rémi Verschelde před 2 roky
rodič
revize
bba753db0d
1 změnil soubory, kde provedl 12 přidání a 8 odebrání
  1. 12 8
      editor/editor_inspector.cpp

+ 12 - 8
editor/editor_inspector.cpp

@@ -2759,26 +2759,30 @@ void EditorInspector::update_tree() {
 			doc_name = p.name;
 
 			// Use category's owner script to update some of its information.
-			if (!EditorNode::get_editor_data().is_type_recognized(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) {
-				StringName script_name;
-
+			if (!EditorNode::get_editor_data().is_type_recognized(type) && p.hint_string.length() && ResourceLoader::exists(p.hint_string)) {
 				Ref<Script> scr = ResourceLoader::load(p.hint_string, "Script");
 				if (scr.is_valid()) {
-					script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
+					StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
 
 					// Update the docs reference and the label based on the script.
 					Vector<DocData::ClassDoc> docs = scr->get_documentation();
 					if (!docs.is_empty()) {
 						doc_name = docs[0].name;
 					}
-					if (script_name != StringName() && label != script_name) {
+					if (script_name != StringName()) {
 						label = script_name;
 					}
+
+					// Find the icon corresponding to the script.
+					if (script_name != StringName()) {
+						category->icon = EditorNode::get_singleton()->get_class_icon(script_name, "Object");
+					} else {
+						category->icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
+					}
 				}
+			}
 
-				// Find the corresponding icon.
-				category->icon = EditorNode::get_singleton()->get_class_icon(script_name, "Object");
-			} else if (!type.is_empty()) {
+			if (category->icon.is_null() && !type.is_empty()) {
 				category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object");
 			}