Hi! I wanted to make an automated tool that would programmatically modify the value of a Component in many blueprints, my approach is to use Reflection in C++ to set a parameter to the SkeletalMeshComponent in an Actor blueprint, first I want to read the SkeletalMeshComponent. Here is my code.
void UFTBPFunctions::MyTestFunction(UObject* InAsset, FString SkeletonName)
{
UBlueprint* Blueprint = Cast<UBlueprint>(InAsset);
auto* AssetCDO = Blueprint->GeneratedClass->GetDefaultObject();
for (TFieldIterator<FProperty> PropIt(AssetCDO->GetClass()); PropIt; ++PropIt)//bp property
{
FProperty* Property = *PropIt;
UE_LOG(LogTemp, Warning, TEXT("Pro is: %s %s"), *Property->GetName(), *Property->GetClass()->GetName());
if (Property->GetName() == SkeletonName)
{
UE_LOG(LogTemp, Warning, TEXT("Found Sk"));
FObjectProperty* SKPro = Cast<FObjectProperty>(Property);
void* ValueAdd = SKPro->ContainerPtrToValuePtr<void>(AssetCDO);
UObject* ActorComponent = SKPro->GetPropertyValue(ValueAdd);
USkeletalMeshComponent* SKcast = Cast <USkeletalMeshComponent>(ActorComponent);
UE_LOG(LogTemp, Warning, TEXT("SKObjet class is: %s"), *(SKcast->GetClass()->GetName()));
}
}
}
My problem is that my SKcast has always been NULlPTR, can anyone point out where my code problem is?