Warn if wrong type while setting material parameter.

This commit is contained in:
Chandler Cox
2024-12-23 16:51:37 -06:00
parent 0f847335c3
commit 88703d721b
2 changed files with 13 additions and 5 deletions

View File

@@ -25,13 +25,20 @@ Variant MaterialBase::GetParameterValue(const StringView& name)
return Variant::Null;
}
void MaterialBase::SetParameterValue(const StringView& name, const Variant& value, bool warnIfMissing)
void MaterialBase::SetParameterValue(const StringView& name, const Variant& value, bool warnIfMissing, bool warnIfWrongType)
{
const auto param = Params.Get(name);
if (param)
{
param->SetValue(value);
param->SetIsOverride(true);
if (param->GetValue().Type == value.Type)
{
param->SetValue(value);
param->SetIsOverride(true);
}
else if (warnIfWrongType)
{
LOG(Warning, "Material parameter '{0}' in material {1} is type '{2}' and not type '{3}'.", String(name), ToString(), param->GetValue().Type, value.Type);
}
}
else if (warnIfMissing)
{