Merge pull request #79258 from KoBeWi/drag_and_drop_anarchy

Assume root when dropping node to unassigned script
This commit is contained in:
Yuri Sizov 2023-08-01 20:03:38 +02:00
commit de0a06ee80

View file

@ -38,6 +38,7 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/gui/editor_toaster.h"
#include "scene/gui/rich_text_label.h" #include "scene/gui/rich_text_label.h"
#include "scene/gui/split_container.h" #include "scene/gui/split_container.h"
@ -1759,10 +1760,14 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
return; return;
} }
if (!ClassDB::is_parent_class(script->get_instance_base_type(), "Node")) {
EditorToaster::get_singleton()->popup_str(vformat(TTR("Can't drop nodes because script '%s' does not inherit Node."), get_name()), EditorToaster::SEVERITY_WARNING);
return;
}
Node *sn = _find_script_node(scene_root, scene_root, script); Node *sn = _find_script_node(scene_root, scene_root, script);
if (!sn) { if (!sn) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Can't drop nodes because script '%s' is not used in this scene."), get_name())); sn = scene_root;
return;
} }
Array nodes = d["nodes"]; Array nodes = d["nodes"];