Improve #3138 to pass over setting value to null and via proper cast so value type stays the same

This commit is contained in:
Wojtek Figat
2025-01-13 16:08:43 +01:00
parent 3796b0ccae
commit 7fcf8c2d4c
2 changed files with 31 additions and 3 deletions

View File

@@ -292,11 +292,12 @@ void AnimatedModel::SetParameterValue(const StringView& name, const Variant& val
{
if (param.Name == name)
{
if (Variant::CanCast(value, param.Value.Type))
if (param.Value.Type == value.Type)
param.Value = value;
else if (Variant::CanCast(value, param.Value.Type))
param.Value = Variant::Cast(value, param.Value.Type);
else
LOG(Warning, "Animation Graph parameter '{0}' in AnimatedModel {1} is type '{2}' and not type '{3}'.", String(name), ToString(), param.Value.Type, value.Type);
LOG(Warning, "Animation Graph parameter '{0}' in AnimatedModel {1} is type '{2}' and not type '{3}'.", name, ToString(), param.Value.Type, value.Type);
return;
}
}