浏览代码

Small fix for problem of nodes losing type, this is not good enough to solve a core reimport problem, but so far fixes #8116

Juan Linietsky 8 年之前
父节点
当前提交
a4f9c95169
共有 3 个文件被更改,包括 15 次插入1 次删除
  1. 6 0
      editor/editor_file_system.cpp
  2. 1 1
      editor/editor_node.cpp
  3. 8 0
      editor/property_editor.cpp

+ 6 - 0
editor/editor_file_system.cpp

@@ -598,6 +598,10 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
 				fi->type = fc->type;
 				fi->modified_time = fc->modification_time;
 				fi->import_modified_time = fc->import_modification_time;
+				if (fc->type == String()) {
+					fi->type = ResourceLoader::get_resource_type(path);
+					//there is also the chance that file type changed due to reimport, must probably check this somehow here (or kind of note it for next time in another file?)
+				}
 
 			} else {
 
@@ -615,6 +619,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
 				}
 
 				fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path);
+				print_line("import extension tried resource type for " + path + " and its " + fi->type);
 				fi->modified_time = 0;
 				fi->import_modified_time = 0;
 
@@ -633,6 +638,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
 				fi->import_modified_time = 0;
 			} else {
 				fi->type = ResourceLoader::get_resource_type(path);
+				print_line("regular import tried resource type for " + path + " and its " + fi->type);
 				fi->modified_time = mt;
 				fi->import_modified_time = 0;
 			}

+ 1 - 1
editor/editor_node.cpp

@@ -1246,7 +1246,7 @@ void EditorNode::_dialog_action(String p_file) {
 				}
 
 			} else {
-				ml.instance();
+				ml = Ref<TileSet>(memnew(TileSet));
 			}
 
 			TileSetEditor::update_library_file(editor_data.get_edited_scene_root(), ml, true);

+ 8 - 0
editor/property_editor.cpp

@@ -2474,11 +2474,14 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction
 
 			String allowed_type = d["hint_text"];
 
+			print_line("allowed type " + allowed_type);
+
 			Dictionary drag_data = p_drag_data;
 			if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
 				Ref<Resource> res = drag_data["resource"];
 				for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
 					String at = allowed_type.get_slice(",", i).strip_edges();
+					print_line("RES vs " + at);
 					if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) {
 						return true;
 					}
@@ -2489,13 +2492,18 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction
 
 				Vector<String> files = drag_data["files"];
 
+				print_line("fileS: " + String(Variant(files)));
 				if (files.size() == 1) {
 					String file = files[0];
 					String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
+
+					print_line("file: " + file);
+					print_line("type: " + ftype);
 					if (ftype != "") {
 
 						for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
 							String at = allowed_type.get_slice(",", i).strip_edges();
+							print_line("FILE vs " + at);
 							if (ClassDB::is_parent_class(ftype, at)) {
 								return true;
 							}