summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp11
-rw-r--r--scene/resources/visual_shader.cpp11
-rw-r--r--scene/resources/visual_shader.h2
3 files changed, 24 insertions, 0 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index b1bd6392d8..294ce2c4cd 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -556,6 +556,17 @@ void VisualShaderEditor::_update_graph() {
uniform_name->connect("text_entered", callable_mp(this, &VisualShaderEditor::_line_edit_changed), varray(uniform_name, nodes[n_i]));
uniform_name->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_line_edit_focus_out), varray(uniform_name, nodes[n_i]));
+ String error = vsnode->get_warning(visual_shader->get_mode(), type);
+ if (error != String()) {
+ offset = memnew(Control);
+ offset->set_custom_minimum_size(Size2(0, 4 * EDSCALE));
+ node->add_child(offset);
+ Label *error_label = memnew(Label);
+ error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
+ error_label->set_text(error);
+ node->add_child(error_label);
+ }
+
if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
//shortcut
VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0);
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index f70f54412b..310a7ef4e4 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -2164,6 +2164,17 @@ void VisualShaderNodeUniform::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "uniform_name"), "set_uniform_name", "get_uniform_name");
}
+String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const {
+
+ List<String> keyword_list;
+ ShaderLanguage::get_keyword_list(&keyword_list);
+ if (keyword_list.find(uniform_name)) {
+ return TTR("Uniform name cannot be equal to a shader keyword. Choose another name.");
+ }
+
+ return String();
+}
+
VisualShaderNodeUniform::VisualShaderNodeUniform() {
}
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 450dcfa081..ecf3f93fbb 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -379,6 +379,8 @@ public:
void set_uniform_name(const String &p_name);
String get_uniform_name() const;
+ virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const;
+
VisualShaderNodeUniform();
};