diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml
index 1e1a6628183..8c3039cb130 100644
--- a/doc/classes/GraphNode.xml
+++ b/doc/classes/GraphNode.xml
@@ -130,6 +130,20 @@
Returns the right (output) custom [Texture2D] of the slot with the given [param slot_index].
+
+
+
+
+ Returns the left (input) metadata of the slot with the given [param slot_index].
+
+
+
+
+
+
+ Returns the right (output) metadata of the slot with the given [param slot_index].
+
+
@@ -249,6 +263,22 @@
Toggles the right (output) side of the slot with the given [param slot_index]. If [param enable] is [code]true[/code], a port will appear on the right side and the slot will be able to be connected from this side.
+
+
+
+
+
+ Sets the custom metadata for the left (input) side of the slot with the given [param slot_index] to [param value].
+
+
+
+
+
+
+
+ Sets the custom metadata for the right (output) side of the slot with the given [param slot_index] to [param value].
+
+
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index c76218ad84a..eaade009377 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -835,6 +835,19 @@ Ref GraphNode::get_slot_custom_icon_left(int p_slot_index) const {
return slot_table[p_slot_index].custom_port_icon_left;
}
+void GraphNode::set_slot_metadata_left(int p_slot_index, const Variant &p_value) {
+ ERR_FAIL_COND_MSG(!slot_table.has(p_slot_index), vformat("Cannot set left metadata for the slot with index '%d' because it hasn't been enabled.", p_slot_index));
+ slot_table[p_slot_index].metadata_left = p_value;
+}
+
+Variant GraphNode::get_slot_metadata_left(int p_slot_index) const {
+ const Slot *slot = slot_table.getptr(p_slot_index);
+ if (slot == nullptr) {
+ return Variant();
+ }
+ return slot->metadata_left;
+}
+
bool GraphNode::is_slot_enabled_right(int p_slot_index) const {
if (!slot_table.has(p_slot_index)) {
return false;
@@ -923,6 +936,19 @@ Ref GraphNode::get_slot_custom_icon_right(int p_slot_index) const {
return slot_table[p_slot_index].custom_port_icon_right;
}
+void GraphNode::set_slot_metadata_right(int p_slot_index, const Variant &p_value) {
+ ERR_FAIL_COND_MSG(!slot_table.has(p_slot_index), vformat("Cannot set right metadata for the slot with index '%d' because it hasn't been enabled.", p_slot_index));
+ slot_table[p_slot_index].metadata_right = p_value;
+}
+
+Variant GraphNode::get_slot_metadata_right(int p_slot_index) const {
+ const Slot *slot = slot_table.getptr(p_slot_index);
+ if (slot == nullptr) {
+ return Variant();
+ }
+ return slot->metadata_right;
+}
+
bool GraphNode::is_slot_draw_stylebox(int p_slot_index) const {
if (!slot_table.has(p_slot_index)) {
return false;
@@ -1229,6 +1255,9 @@ void GraphNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_slot_custom_icon_left", "slot_index", "custom_icon"), &GraphNode::set_slot_custom_icon_left);
ClassDB::bind_method(D_METHOD("get_slot_custom_icon_left", "slot_index"), &GraphNode::get_slot_custom_icon_left);
+ ClassDB::bind_method(D_METHOD("set_slot_metadata_left", "slot_index", "value"), &GraphNode::set_slot_metadata_left);
+ ClassDB::bind_method(D_METHOD("get_slot_metadata_left", "slot_index"), &GraphNode::get_slot_metadata_left);
+
ClassDB::bind_method(D_METHOD("is_slot_enabled_right", "slot_index"), &GraphNode::is_slot_enabled_right);
ClassDB::bind_method(D_METHOD("set_slot_enabled_right", "slot_index", "enable"), &GraphNode::set_slot_enabled_right);
@@ -1241,6 +1270,9 @@ void GraphNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_slot_custom_icon_right", "slot_index", "custom_icon"), &GraphNode::set_slot_custom_icon_right);
ClassDB::bind_method(D_METHOD("get_slot_custom_icon_right", "slot_index"), &GraphNode::get_slot_custom_icon_right);
+ ClassDB::bind_method(D_METHOD("set_slot_metadata_right", "slot_index", "value"), &GraphNode::set_slot_metadata_right);
+ ClassDB::bind_method(D_METHOD("get_slot_metadata_right", "slot_index"), &GraphNode::get_slot_metadata_right);
+
ClassDB::bind_method(D_METHOD("is_slot_draw_stylebox", "slot_index"), &GraphNode::is_slot_draw_stylebox);
ClassDB::bind_method(D_METHOD("set_slot_draw_stylebox", "slot_index", "enable"), &GraphNode::set_slot_draw_stylebox);
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index e8e20f05c67..bdbc11926c3 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -44,11 +44,13 @@ class GraphNode : public GraphElement {
int type_left = 0;
Color color_left = Color(1, 1, 1, 1);
Ref custom_port_icon_left;
+ Variant metadata_left;
bool enable_right = false;
int type_right = 0;
Color color_right = Color(1, 1, 1, 1);
Ref custom_port_icon_right;
+ Variant metadata_right;
bool draw_stylebox = true;
};
@@ -150,6 +152,9 @@ public:
void set_slot_custom_icon_left(int p_slot_index, const Ref &p_custom_icon);
Ref get_slot_custom_icon_left(int p_slot_index) const;
+ void set_slot_metadata_left(int p_slot_index, const Variant &p_value);
+ Variant get_slot_metadata_left(int p_slot_index) const;
+
bool is_slot_enabled_right(int p_slot_index) const;
void set_slot_enabled_right(int p_slot_index, bool p_enable);
@@ -162,6 +167,9 @@ public:
void set_slot_custom_icon_right(int p_slot_index, const Ref &p_custom_icon);
Ref get_slot_custom_icon_right(int p_slot_index) const;
+ void set_slot_metadata_right(int p_slot_index, const Variant &p_value);
+ Variant get_slot_metadata_right(int p_slot_index) const;
+
bool is_slot_draw_stylebox(int p_slot_index) const;
void set_slot_draw_stylebox(int p_slot_index, bool p_enable);