diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml
index 7187617c4c6a..740be3f47f6c 100644
--- a/doc/classes/EditorInterface.xml
+++ b/doc/classes/EditorInterface.xml
@@ -150,6 +150,12 @@
Returns an [Array] with the file paths of the currently opened scenes.
+
+
+
+ Returns an [Array] with the root nodes of the currently opened scenes.
+
+
diff --git a/editor/editor_interface.cpp b/editor/editor_interface.cpp
index 46113ab2cbeb..60f190b906fc 100644
--- a/editor/editor_interface.cpp
+++ b/editor/editor_interface.cpp
@@ -435,6 +435,20 @@ PackedStringArray EditorInterface::get_open_scenes() const {
return ret;
}
+Array EditorInterface::get_open_scenes_roots() const {
+ Array ret;
+ Vector scenes = EditorNode::get_editor_data().get_edited_scenes();
+
+ int scns_amount = scenes.size();
+ for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
+ if (scenes[idx_scn].root == nullptr) {
+ continue;
+ }
+ ret.push_back(scenes[idx_scn].root);
+ }
+ return ret;
+}
+
Error EditorInterface::save_scene() {
if (!get_edited_scene_root()) {
return ERR_CANT_CREATE;
@@ -583,6 +597,7 @@ void EditorInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);
+ ClassDB::bind_method(D_METHOD("get_open_scenes_roots"), &EditorInterface::get_open_scenes_roots);
ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root);
ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
diff --git a/editor/editor_interface.h b/editor/editor_interface.h
index 3ef4325780a2..1cae48323f1a 100644
--- a/editor/editor_interface.h
+++ b/editor/editor_interface.h
@@ -151,6 +151,7 @@ class EditorInterface : public Object {
void reload_scene_from_path(const String &scene_path);
PackedStringArray get_open_scenes() const;
+ Array get_open_scenes_roots() const;
Node *get_edited_scene_root() const;
Error save_scene();