Fix crash hen readingBehaviorKnowledgeSelector value in C# when type doesn't match exactly

This commit is contained in:
Wojtek Figat
2023-11-14 11:47:44 +01:00
parent 3320c76e14
commit 0360f7786d
2 changed files with 74 additions and 3 deletions

View File

@@ -202,7 +202,7 @@ namespace FlaxEngine
public T Get(BehaviorKnowledge knowledge)
{
if (knowledge != null && knowledge.Get(Path, out var value))
return (T)value;
return Utilities.VariantUtils.Cast<T>(value);
return default;
}
@@ -218,7 +218,7 @@ namespace FlaxEngine
object tmp = null;
bool result = knowledge != null && knowledge.Get(Path, out tmp);
if (result)
value = (T)tmp;
value = Utilities.VariantUtils.Cast<T>(tmp);
return result;
}