mirror of https://github.com/godotengine/godot
Merge pull request #107013 from Rindbee/fix-wrong-node-path-in-connection-dialog
Fix the extra arguments of type `NodePath` in the connection dialog do not work
This commit is contained in:
commit
8c956babeb
|
|
@ -3089,6 +3089,11 @@ void EditorPropertyNodePath::_notification(int p_what) {
|
|||
Node *EditorPropertyNodePath::get_base_node() {
|
||||
Node *base_node = Object::cast_to<Node>(get_edited_object());
|
||||
|
||||
// For proxy objects, specifies the node to which the path is relative.
|
||||
if (!base_node && get_edited_object()->has_meta("__base_node_relative")) {
|
||||
base_node = Object::cast_to<Node>(get_edited_object()->get_meta("__base_node_relative"));
|
||||
}
|
||||
|
||||
if (!base_node) {
|
||||
base_node = Object::cast_to<Node>(InspectorDock::get_inspector_singleton()->get_edited_object());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,33 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void update_base_node_relative(Node *p_node) {
|
||||
Node *old_base = nullptr;
|
||||
if (has_meta("__base_node_relative")) {
|
||||
old_base = Object::cast_to<Node>(get_meta("__base_node_relative"));
|
||||
}
|
||||
|
||||
if (old_base == p_node) {
|
||||
return;
|
||||
}
|
||||
// The cdbinds is a proxy object, so we want the node path to be relative to the target node.
|
||||
set_meta("__base_node_relative", p_node);
|
||||
|
||||
if (!old_base) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update existing outdated node paths.
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
if (params[i].get_type() != Variant::NODE_PATH) {
|
||||
continue;
|
||||
}
|
||||
StringName property_name = "bind/argument_" + itos(i + 1);
|
||||
Node *n = old_base->get_node(get(property_name));
|
||||
set(property_name, p_node ? p_node->get_path_to(n) : NodePath());
|
||||
}
|
||||
}
|
||||
|
||||
void notify_changed() {
|
||||
notify_property_list_changed();
|
||||
}
|
||||
|
|
@ -176,6 +203,9 @@ void ConnectDialog::_tree_node_selected() {
|
|||
if (!edit_mode) {
|
||||
set_dst_method(generate_method_callback_name(source, signal, current));
|
||||
}
|
||||
|
||||
cdbinds->update_base_node_relative(current);
|
||||
|
||||
_update_method_tree();
|
||||
_update_warning_label();
|
||||
_update_ok_enabled();
|
||||
|
|
|
|||
Loading…
Reference in New Issue