Skip to content

Commit 3f272f4

Browse files
committed
Assume root when dropping node to unassigned script
1 parent dcd187d commit 3f272f4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

editor/plugins/script_text_editor.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "editor/editor_node.h"
3939
#include "editor/editor_scale.h"
4040
#include "editor/editor_settings.h"
41+
#include "editor/gui/editor_toaster.h"
4142
#include "scene/gui/rich_text_label.h"
4243
#include "scene/gui/split_container.h"
4344

@@ -1759,10 +1760,14 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
17591760
return;
17601761
}
17611762

1763+
if (!ClassDB::is_parent_class(script->get_instance_base_type(), "Node")) {
1764+
EditorToaster::get_singleton()->popup_str(vformat(TTR("Can't drop nodes because script '%s' does not inherit Node."), get_name()), EditorToaster::SEVERITY_WARNING);
1765+
return;
1766+
}
1767+
17621768
Node *sn = _find_script_node(scene_root, scene_root, script);
17631769
if (!sn) {
1764-
EditorNode::get_singleton()->show_warning(vformat(TTR("Can't drop nodes because script '%s' is not used in this scene."), get_name()));
1765-
return;
1770+
sn = scene_root;
17661771
}
17671772

17681773
Array nodes = d["nodes"];

0 commit comments

Comments
 (0)