Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get_open_scenes_roots API to Editor Interface to retrieve all opened scenes root nodes #97838

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/classes/EditorInterface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
Returns an [Array] with the file paths of the currently opened scenes.
</description>
</method>
<method name="get_open_scenes_roots" qualifiers="const">
<return type="Array" />
<description>
Returns an [Array] with the root nodes of the currently opened scenes.
</description>
</method>
<method name="get_playing_scene" qualifiers="const">
<return type="String" />
<description>
Expand Down
15 changes: 15 additions & 0 deletions editor/editor_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,20 @@ PackedStringArray EditorInterface::get_open_scenes() const {
return ret;
}

Array EditorInterface::get_open_scenes_roots() const {
Array ret;
Vector<EditorData::EditedScene> 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;
Expand Down Expand Up @@ -616,6 +630,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);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,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();
Expand Down