summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2020-04-06 10:25:05 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2020-04-06 12:29:50 +0300
commit8dfe6716ec7204c110a2977eb22bd74029b32c36 (patch)
tree283449664b0f27879699d013231cc00a248ef5d8 /scene
parent1140871f7e5b627bcd5c11e073975ed21421a95c (diff)
Adds warning to the uniform name in visual shader if its equal to keyword
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/visual_shader.cpp11
-rw-r--r--scene/resources/visual_shader.h2
2 files changed, 13 insertions, 0 deletions
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();
};