Hello!
After many attempts, I succeeded in accessing an AnimBP variable (type FLiveLinkSubjectName) using FindPropertyByName(), FProperty, and FStructProperty.
But I still have a problem that I haven’t been able to solve.
I want to change the value of FLiveLinkSubjectName.Name. I tried to change FProperty* or FStructProperty* to FLiveLinkSubjectName* type, but all failed. The code below is the most recent attempt, and crash occurred.
How can I change the value of FLiveLinkSubjectName type variable in AnimBP?..
void AMain::TempFunction(UObject* AnimBP, FString TargetLiveLinkSubjectName, FString NewName)
{
if (AnimBP)
{
UClass* AnimBPClass = AnimBP->GetClass();
if (AnimBPClass)
{
FProperty* Prop = AnimBPClass->FindPropertyByName(FName(*TargetLiveLinkSubjectName));
if (Prop)
{
FStructProperty* StructProp = CastField<FStructProperty>(Prop);
if (StructProp)
{
FLiveLinkSubjectName* LiveLinkSubjectName = reinterpret_cast<FLiveLinkSubjectName*>(StructProp);
if (LiveLinkSubjectName)
{
//crash!
LiveLinkSubjectName->Name = FName(*NewName);
UE_LOG(LogTemp, Warning, TEXT("!!!"));
}
}
}
}
}
}