mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 22:21:18 +00:00
Update the edit scene root in time after it is replaced
When changing the type of the edited scene root node, it may be necessary to update edited scene root in time for the child nodes to work properly.
This commit is contained in:
parent
9f12e7b52d
commit
eb74079dfb
4 changed files with 17 additions and 8 deletions
|
|
@ -3430,10 +3430,12 @@ void EditorNode::_remove_scene(int index, bool p_change_tab) {
|
|||
}
|
||||
|
||||
void EditorNode::set_edited_scene(Node *p_scene) {
|
||||
if (get_editor_data().get_edited_scene_root()) {
|
||||
if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root) {
|
||||
scene_root->remove_child(get_editor_data().get_edited_scene_root());
|
||||
Node *old_edited_scene_root = get_editor_data().get_edited_scene_root();
|
||||
if (old_edited_scene_root) {
|
||||
if (old_edited_scene_root->get_parent() == scene_root) {
|
||||
scene_root->remove_child(old_edited_scene_root);
|
||||
}
|
||||
old_edited_scene_root->disconnect(SNAME("replacing_by"), callable_mp(this, &EditorNode::set_edited_scene));
|
||||
}
|
||||
get_editor_data().set_edited_scene_root(p_scene);
|
||||
|
||||
|
|
@ -3449,6 +3451,7 @@ void EditorNode::set_edited_scene(Node *p_scene) {
|
|||
if (p_scene->get_parent() != scene_root) {
|
||||
scene_root->add_child(p_scene, true);
|
||||
}
|
||||
p_scene->connect(SNAME("replacing_by"), callable_mp(this, &EditorNode::set_edited_scene));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue