Skip to content

Commit 48eebb7

Browse files
committed
Warn if setting non-existend shader parameter
1 parent 7893202 commit 48eebb7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scene/resources/material.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,20 @@ void ShaderMaterial::set_shader_parameter(const StringName &p_param, const Varia
454454
} else {
455455
Variant *v = param_cache.getptr(p_param);
456456
if (!v) {
457+
#ifdef TOOLS_ENABLED
458+
bool missing;
459+
if (param_cache.is_empty()) {
460+
// Build parameter cache.
461+
List<PropertyInfo> l;
462+
_get_property_list(&l);
463+
missing = !param_cache.has(p_param);;
464+
} else {
465+
missing = true;
466+
}
467+
if (missing) {
468+
WARN_PRINT(vformat("Shader parameter \"%s\" not found in Shader.", p_param));
469+
}
470+
#endif
457471
// Never assigned, also update the remap cache.
458472
remap_cache["shader_parameter/" + p_param.operator String()] = p_param;
459473
param_cache.insert(p_param, p_value);

0 commit comments

Comments
 (0)