You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Fix printing error about unsupported modifier on TransformUniform
This commit is contained in:
@@ -3081,10 +3081,84 @@ String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::T
|
||||
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 TTR("Shader keywords cannot be used as uniform names.\nChoose another name.");
|
||||
}
|
||||
if (!is_qualifier_supported(qualifier)) {
|
||||
return "This uniform type does not support that qualifier.";
|
||||
String qualifier_str;
|
||||
switch (qualifier) {
|
||||
case QUAL_NONE:
|
||||
break;
|
||||
case QUAL_GLOBAL:
|
||||
qualifier_str = "global";
|
||||
break;
|
||||
case QUAL_INSTANCE:
|
||||
qualifier_str = "instance";
|
||||
break;
|
||||
}
|
||||
return vformat(TTR("This uniform type does not support the '%s' qualifier."), qualifier_str);
|
||||
} else if (qualifier == Qualifier::QUAL_GLOBAL) {
|
||||
RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(uniform_name);
|
||||
if (gvt == RS::GLOBAL_VAR_TYPE_MAX) {
|
||||
return vformat(TTR("Global uniform '%s' does not exist.\nCreate it in the Project Settings."), uniform_name);
|
||||
}
|
||||
bool incompatible_type = false;
|
||||
switch (gvt) {
|
||||
case RS::GLOBAL_VAR_TYPE_FLOAT: {
|
||||
if (!Object::cast_to<VisualShaderNodeFloatUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_INT: {
|
||||
if (!Object::cast_to<VisualShaderNodeIntUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL: {
|
||||
if (!Object::cast_to<VisualShaderNodeBooleanUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_COLOR: {
|
||||
if (!Object::cast_to<VisualShaderNodeColorUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_VEC3: {
|
||||
if (!Object::cast_to<VisualShaderNodeVec3Uniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
|
||||
if (!Object::cast_to<VisualShaderNodeTransformUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLER2D: {
|
||||
if (!Object::cast_to<VisualShaderNodeTextureUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLER3D: {
|
||||
if (!Object::cast_to<VisualShaderNodeTexture3DUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: {
|
||||
if (!Object::cast_to<VisualShaderNodeTexture2DArrayUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE: {
|
||||
if (!Object::cast_to<VisualShaderNodeCubemapUniform>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (incompatible_type) {
|
||||
return vformat(TTR("Global uniform '%s' has an incompatible type for this kind of node.\nChange it in the Project Settings."), uniform_name);
|
||||
}
|
||||
}
|
||||
|
||||
return String();
|
||||
|
||||
Reference in New Issue
Block a user