diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-08-17 11:55:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-17 11:55:48 +0200 |
commit | fe8f73c939d40ad32a43289fce18322b54b5ef67 (patch) | |
tree | 8a63320fcaa1af451fa18ab937d2b012469f0d68 | |
parent | be42f1bf6cd1fa18321bbd24b77955ddcd535f7e (diff) | |
parent | c9445a0faa425abbdeff2443550c096dc3b207e3 (diff) |
Merge pull request #31422 from sparkart/attachscript_by_scripteditor
Adds Attaching Script via Script Editor
-rw-r--r-- | editor/scene_tree_editor.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 2d9accc3d8..458d8273c5 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -995,6 +995,17 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d return true; } + if (String(d["type"]) == "script_list_element") { + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(d["script_list_element"]); + if (se) { + String sp = se->get_edited_resource()->get_path(); + if (_is_script_type(EditorFileSystem::get_singleton()->get_file_type(sp))) { + tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM); + return true; + } + } + } + return String(d["type"]) == "nodes"; } void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { @@ -1032,6 +1043,16 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, emit_signal("files_dropped", files, np, section); } } + + if (String(d["type"]) == "script_list_element") { + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(d["script_list_element"]); + if (se) { + String sp = se->get_edited_resource()->get_path(); + if (_is_script_type(EditorFileSystem::get_singleton()->get_file_type(sp))) { + emit_signal("script_dropped", sp, np); + } + } + } } void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) { |