I am trying to load data from a file into a blueprint TArray variable.
I dont know how to cast the TArray to FScriptArray correctly or is that the issue?
bool UCronoGameDataHelper::SetBoolArrayByName(UObject * target, FName varName, TArray<bool> newVar)
{
UArrayProperty* arrayProp = FindField<UArrayProperty>(target->GetClass(), varName);
if (arrayProp && arrayProp->Inner->IsA<UBoolProperty>())
{
const FScriptArray& sArray = (const FScriptArray&)newVar;
// TODO: Cast does not work?
arrayProp->SetPropertyValue_InContainer(target, sArray); // This is causing an error
return true;
}
// TODO: Add logging
return false;
}
When arrayProp->SetPropertyValue_InContainer(target, sArray); is called I get void operator=(const FScriptArray&) { check(false); } failing from ScriptsArray.h
Im on 4.19