Browse Source

MultiNodeEdit Fix setting NodePath

(cherry picked from commit 5260fd8f3eac1c0ac2e50b13ff1fa10f44823e3e)
kleonc 4 years ago
parent
commit
7c981804b7
1 changed files with 10 additions and 3 deletions
  1. 10 3
      editor/multi_node_edit.cpp

+ 10 - 3
editor/multi_node_edit.cpp

@@ -48,6 +48,11 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
 		name = "script";
 		name = "script";
 	}
 	}
 
 
+	Node *node_path_target = nullptr;
+	if (p_value.get_type() == Variant::NODE_PATH && p_value != NodePath()) {
+		node_path_target = es->get_node(p_value);
+	}
+
 	UndoRedo *ur = EditorNode::get_undo_redo();
 	UndoRedo *ur = EditorNode::get_undo_redo();
 
 
 	ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS);
 	ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS);
@@ -61,9 +66,11 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
 			continue;
 			continue;
 
 
 		if (p_value.get_type() == Variant::NODE_PATH) {
 		if (p_value.get_type() == Variant::NODE_PATH) {
-			Node *tonode = n->get_node(p_value);
-			NodePath p_path = n->get_path_to(tonode);
-			ur->add_do_property(n, name, p_path);
+			NodePath path;
+			if (node_path_target) {
+				path = n->get_path_to(node_path_target);
+			}
+			ur->add_do_property(n, name, path);
 		} else {
 		} else {
 			Variant new_value;
 			Variant new_value;
 			if (p_field == "") {
 			if (p_field == "") {