diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-07-23 13:06:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-23 13:06:03 +0200 |
commit | c6691076263aad2ddffb9b0b4c3c2a00a93a2070 (patch) | |
tree | 25d4f80acb00e290d1d28098c66ee0b42d4c51e6 | |
parent | e5aa8546ec0458e8eae84c260b3633a0313f9848 (diff) | |
parent | 19ca9e7810decf430efd559487e99734b7621571 (diff) |
Merge pull request #9741 from vnen/fix-vs-customnode
Fix issues with custom nodes in visual script
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 14 | ||||
-rw-r--r-- | modules/visual_script/visual_script_nodes.h | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 9cbadde521..771d0463c8 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -29,10 +29,10 @@ /*************************************************************************/ #include "visual_script_nodes.h" -#include "project_settings.h" #include "global_constants.h" #include "os/input.h" #include "os/os.h" +#include "project_settings.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" @@ -2596,10 +2596,10 @@ public: in_values.resize(in_count); for (int i = 0; i < in_count; i++) { - in_values[i] = p_inputs[i]; + in_values[i] = *p_inputs[i]; } - out_values.resize(in_count); + out_values.resize(out_count); work_mem.resize(work_mem_size); @@ -2645,6 +2645,7 @@ VisualScriptNodeInstance *VisualScriptCustomNode::instance(VisualScriptInstance VisualScriptNodeInstanceCustomNode *instance = memnew(VisualScriptNodeInstanceCustomNode); instance->instance = p_instance; + instance->node = this; instance->in_count = get_input_value_port_count(); instance->out_count = get_output_value_port_count(); @@ -2657,6 +2658,10 @@ VisualScriptNodeInstance *VisualScriptCustomNode::instance(VisualScriptInstance return instance; } +void VisualScriptCustomNode::_script_changed() { + ports_changed_notify(); +} + void VisualScriptCustomNode::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_sequence_port_count")); @@ -2679,6 +2684,8 @@ void VisualScriptCustomNode::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::INT, "_get_working_memory_size")); BIND_VMETHOD(MethodInfo(Variant::NIL, "_step:Variant", PropertyInfo(Variant::ARRAY, "inputs"), PropertyInfo(Variant::ARRAY, "outputs"), PropertyInfo(Variant::INT, "start_mode"), PropertyInfo(Variant::ARRAY, "working_mem"))); + ClassDB::bind_method(D_METHOD("_script_changed"), &VisualScriptCustomNode::_script_changed); + BIND_CONSTANT(START_MODE_BEGIN_SEQUENCE); BIND_CONSTANT(START_MODE_CONTINUE_SEQUENCE); BIND_CONSTANT(START_MODE_RESUME_YIELD); @@ -2691,6 +2698,7 @@ void VisualScriptCustomNode::_bind_methods() { } VisualScriptCustomNode::VisualScriptCustomNode() { + connect("script_changed", this, "_script_changed"); } ////////////////////////////////////////// diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index 5ae9a1b30b..7a3b26fe55 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -712,6 +712,8 @@ public: virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); + void _script_changed(); + VisualScriptCustomNode(); }; |