diff --git a/doc/classes/MissingNode.xml b/doc/classes/MissingNode.xml
index 9171c8321f2..d6d1ac0f01a 100644
--- a/doc/classes/MissingNode.xml
+++ b/doc/classes/MissingNode.xml
@@ -19,5 +19,8 @@
If [code]true[/code], allows new properties to be set along with existing ones. If [code]false[/code], only existing properties' values can be set, and new properties cannot be added.
+
+ If [code]true[/code], allows new signals to be connected to along with existing ones. If [code]false[/code], only existing signals can be connected to, and new signals cannot be added.
+
diff --git a/scene/main/missing_node.cpp b/scene/main/missing_node.cpp
index f071ea59a0a..10d426dd018 100644
--- a/scene/main/missing_node.cpp
+++ b/scene/main/missing_node.cpp
@@ -58,6 +58,17 @@ void MissingNode::_get_property_list(List *p_list) const {
}
}
+#ifdef DEBUG_ENABLED
+Error MissingNode::connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags) {
+ if (is_recording_signals()) {
+ if (!has_signal(p_signal)) {
+ add_user_signal(MethodInfo(p_signal));
+ }
+ }
+ return Object::connect(p_signal, p_callable, p_flags);
+}
+#endif
+
void MissingNode::set_original_class(const String &p_class) {
original_class = p_class;
}
@@ -82,6 +93,14 @@ bool MissingNode::is_recording_properties() const {
return recording_properties;
}
+void MissingNode::set_recording_signals(bool p_enable) {
+ recording_signals = p_enable;
+}
+
+bool MissingNode::is_recording_signals() const {
+ return recording_signals;
+}
+
PackedStringArray MissingNode::get_configuration_warnings() const {
// The mere existence of this node is warning.
PackedStringArray warnings = Node::get_configuration_warnings();
@@ -107,10 +126,14 @@ void MissingNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_recording_properties", "enable"), &MissingNode::set_recording_properties);
ClassDB::bind_method(D_METHOD("is_recording_properties"), &MissingNode::is_recording_properties);
+ ClassDB::bind_method(D_METHOD("set_recording_signals", "enable"), &MissingNode::set_recording_signals);
+ ClassDB::bind_method(D_METHOD("is_recording_signals"), &MissingNode::is_recording_signals);
+
// Expose, but not save.
ADD_PROPERTY(PropertyInfo(Variant::STRING, "original_class", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_original_class", "get_original_class");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "original_scene", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_original_scene", "get_original_scene");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recording_properties", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_recording_properties", "is_recording_properties");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recording_signals", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_recording_signals", "is_recording_signals");
}
MissingNode::MissingNode() {
diff --git a/scene/main/missing_node.h b/scene/main/missing_node.h
index b986655e748..c8681b90f87 100644
--- a/scene/main/missing_node.h
+++ b/scene/main/missing_node.h
@@ -39,12 +39,17 @@ class MissingNode : public Node {
String original_class;
String original_scene;
bool recording_properties = false;
+ bool recording_signals = false;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List *p_list) const;
+#ifdef DEBUG_ENABLED
+ virtual Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0) override;
+#endif
+
static void _bind_methods();
public:
@@ -57,6 +62,9 @@ public:
void set_recording_properties(bool p_enable);
bool is_recording_properties() const;
+ void set_recording_signals(bool p_enable);
+ bool is_recording_signals() const;
+
virtual PackedStringArray get_configuration_warnings() const override;
MissingNode();