MultiNodeEdit Fix setting NodePath

This commit is contained in:
kleonc 2021-08-22 17:17:30 +02:00
parent f303c2dfb5
commit 5260fd8f3e

View file

@ -49,6 +49,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);
@ -63,9 +68,11 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
} }
if (p_value.get_type() == Variant::NODE_PATH) { if (p_value.get_type() == Variant::NODE_PATH) {
Node *tonode = n->get_node(p_value); NodePath path;
NodePath p_path = n->get_path_to(tonode); if (node_path_target) {
ur->add_do_property(n, name, p_path); 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 == "") {