@@ -49,6 +49,7 @@ void MultiGodot::_bind_methods() {
4949 ClassDB::bind_method (D_METHOD (" _set_as_script_owner" , " path" ), &MultiGodot::_set_as_script_owner);
5050 ClassDB::bind_method (D_METHOD (" _apply_action" ), &MultiGodot::_apply_action);
5151 ClassDB::bind_method (D_METHOD (" _instantiate_resource" , " node_path" , " resource_path" , " type" ), &MultiGodot::_instantiate_resource);
52+ ClassDB::bind_method (D_METHOD (" _move_node" , " old" , " new" ), &MultiGodot::_move_node);
5253
5354 // Button signals
5455
@@ -603,10 +604,14 @@ void MultiGodot::_sync_colab_scenes() {
603604 selected = scene_tree_editor->get_selected (); if (selected == nullptr ) return ;
604605 Node *root = EditorNode::get_singleton ()->get_edited_scene ();
605606
607+ String selected_path = root->get_path_to (selected);
608+
606609 List<PropertyInfo> *property_infos = memnew (List<PropertyInfo>);
607610 selected->get_property_list (property_infos);
608611
609612 if (selected != previous_selected_node) {
613+ last_selected_path = selected_path;
614+
610615 previous_property_names.clear ();
611616 previous_property_values.clear ();
612617
@@ -616,6 +621,13 @@ void MultiGodot::_sync_colab_scenes() {
616621 return ;
617622 }
618623
624+ if (last_selected_path != selected_path) { // Node was moved.
625+ String new_parent_path = root->get_path_to (selected->get_parent ());
626+ _call_func (this , " _move_node" , {last_selected_path, new_parent_path});
627+ }
628+
629+ last_selected_path = selected_path;
630+
619631 _recurse_node_parameters (root, selected, root->get_path_to (selected));
620632}
621633
@@ -1025,8 +1037,7 @@ void MultiGodot::_set_as_script_owner(String path) {
10251037 _set_user_data_for_everyone (" current_spectating_script" , " " );
10261038}
10271039
1028- void MultiGodot::_apply_action (int type, String node_path, String new_path, String new_name, String property_path,
1029- Variant new_value) {
1040+ void MultiGodot::_apply_action (int type, String node_path, String new_path, String new_name, String property_path, Variant new_value) {
10301041 if (type == Action::PROPERTY_EDIT) {
10311042 Object *modified_on = EditorNode::get_singleton ()->get_edited_scene ()->get_node (node_path);
10321043
@@ -1098,6 +1109,27 @@ void MultiGodot::_instantiate_resource(String node_path, String resource_path, S
10981109
10991110}
11001111
1112+ void MultiGodot::_move_node (String current_path, String new_parent_path) {
1113+ SceneTreeEditor *scene_tree_editor = SceneTreeDock::get_singleton ()->get_tree_editor ();
1114+ Node *root = EditorNode::get_singleton ()->get_edited_scene ();
1115+
1116+ Node *moved = root->get_node (current_path);
1117+ if (!moved) {
1118+ print_error (" Request to move node but the node at path " + current_path + " does not exist. Was it moved?" );
1119+ return ;
1120+ }
1121+
1122+ Node *parent = root->get_node (new_parent_path);
1123+ if (!parent) {
1124+ print_error (" Request to move a node (that exists) to a parent that doesn't exist at path " + new_parent_path + " . No parents?" );
1125+ return ;
1126+ }
1127+
1128+ // Remove the child and give it to new parents.
1129+ moved->get_parent ()->remove_child (moved);
1130+ parent->add_child (moved);
1131+ }
1132+
11011133// SIGNALS
11021134
11031135void MultiGodot::_on_lobby_created (int connect, uint64_t this_lobby_id) {
0 commit comments