summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2021-04-12 13:47:37 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2021-04-12 14:41:08 +0300
commit8d3e46098be4ca984c035b42f79771925bbc3504 (patch)
tree296de06861464363c43f653f792d87481314d1b7 /editor
parentcee5414698b14be3ce837b4c9de3a3d500d28611 (diff)
Prevents default values of VSNodeCustom from overriding by a script
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index b2fa9c540e..f680314fe5 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -353,6 +353,11 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
bool is_expression = !expression_node.is_null();
String expression = "";
+ VisualShaderNodeCustom *custom_node = Object::cast_to<VisualShaderNodeCustom>(vsnode.ptr());
+ if (custom_node) {
+ custom_node->_set_initialized(true);
+ }
+
GraphNode *node = memnew(GraphNode);
register_link(p_type, p_id, vsnode.ptr(), node);
@@ -1772,8 +1777,15 @@ void VisualShaderEditor::_port_edited() {
ERR_FAIL_COND(!vsn.is_valid());
undo_redo->create_action(TTR("Set Input Default Port"));
- undo_redo->add_do_method(vsn.ptr(), "set_input_port_default_value", editing_port, value);
- undo_redo->add_undo_method(vsn.ptr(), "set_input_port_default_value", editing_port, vsn->get_input_port_default_value(editing_port));
+
+ Ref<VisualShaderNodeCustom> custom = Object::cast_to<VisualShaderNodeCustom>(vsn.ptr());
+ if (custom.is_valid()) {
+ undo_redo->add_do_method(custom.ptr(), "_set_input_port_default_value", editing_port, value);
+ undo_redo->add_undo_method(custom.ptr(), "_set_input_port_default_value", editing_port, vsn->get_input_port_default_value(editing_port));
+ } else {
+ undo_redo->add_do_method(vsn.ptr(), "set_input_port_default_value", editing_port, value);
+ undo_redo->add_undo_method(vsn.ptr(), "set_input_port_default_value", editing_port, vsn->get_input_port_default_value(editing_port));
+ }
undo_redo->add_do_method(graph_plugin.ptr(), "set_input_port_default_value", type, editing_node, editing_port, value);
undo_redo->add_undo_method(graph_plugin.ptr(), "set_input_port_default_value", type, editing_node, editing_port, vsn->get_input_port_default_value(editing_port));
undo_redo->commit_action();