summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-10-16 11:42:49 +0200
committerGitHub <noreply@github.com>2018-10-16 11:42:49 +0200
commitd36f33a2272385d527b0ebde8bfaf62eccc51a06 (patch)
treeb3d6fbec82ff7295887ef5d7b85748824fc2d0d0
parent4c863da4d5ad86f4c392d72dd9dbe24801884a71 (diff)
parentd3fc5e6c8933c156d449d8cc0bfa5d0075d74333 (diff)
Merge pull request #22944 from fire/visual-script-constructor-21840
Fixed the problem with vector3 constructor
-rw-r--r--modules/visual_script/visual_script.cpp20
-rw-r--r--modules/visual_script/visual_script.h1
2 files changed, 12 insertions, 9 deletions
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index ff97c21fd9..52a30baaec 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -48,20 +48,22 @@ bool VisualScriptNode::is_breakpoint() const {
void VisualScriptNode::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
-
- int dvc = get_input_value_port_count();
- for (int i = 0; i < dvc; i++) {
- Variant::Type expected = get_input_value_port_info(i).type;
- Variant::CallError ce;
- default_input_values.push_back(Variant::construct(expected, NULL, 0, ce, false));
- }
+ _update_input_ports();
}
}
-void VisualScriptNode::ports_changed_notify() {
-
+void VisualScriptNode::_update_input_ports() {
default_input_values.resize(MAX(default_input_values.size(), get_input_value_port_count())); //let it grow as big as possible, we don't want to lose values on resize
+ int port_count = get_input_value_port_count();
+ for (int i = 0; i < port_count; i++) {
+ Variant::Type expected = get_input_value_port_info(i).type;
+ Variant::CallError ce;
+ set_default_input_value(i, Variant::construct(expected, NULL, 0, ce, false));
+ }
+}
+void VisualScriptNode::ports_changed_notify() {
+ _update_input_ports();
emit_signal("ports_changed");
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index ea99ce4970..bd666447a3 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -52,6 +52,7 @@ class VisualScriptNode : public Resource {
Array _get_default_input_values() const;
void validate_input_default_values();
+ void _update_input_ports();
protected:
void _notification(int p_what);